Skip to content
Snippets Groups Projects
Commit 93f42e98 authored by Mukesh Agrawal's avatar Mukesh Agrawal Committed by CQ bot account: commit-bot@chromium.org
Browse files

[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
parent 095f09bc
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment