[benchmarks] reduce setup time for RandomMemcpy benchmark
Allocating the memory buffer for RandomMemcpy can be very slow. In some manual testing on Eve, the buffer allocation appeared to take 4-8 seconds. This is with a debug build which uses -O0, and the std::vector constructor will produce code that does a function call for every byte in the 128MB buffer. (In release builds, the compiler will optimise that to a memcpy(). When unoptimised, it's very slow.) Optimize the buffer allocation, by using a primitive array, rather than a std::vector. We fill the array before reading from it, to ensure that we do not cause any reads of unitialized memory. The net result of the optimization is that the time to run the benchmarks in "unit-test-mode", on my Eve, drops from ~2 minutes to ~30 seconds. Bug: FLK-124 #done Test: /pkgfs/packages/zircon_benchmarks/0/test/zircon_benchmarks (on eve) Test: /pkgfs/packages/zircon_benchmarks/0/test/zircon_benchmarks -p (on eve) Change-Id: I449a304a60ccee6a137e9371ca4455b8840fedde
Loading
Please register or sign in to comment