tools/cygprofile: Add unit and performance tests to lightweight_cygprofile.

This adds unit tests to lightweight_cygprofile, and performance tests,
similar to the ones for cygprofile.cc. Using the same tests as the ones
in 72aed26f38a0f5a7be558eb44ba06d7739d77e72 on the same device (Nexus
5X):

cygprofile.cc (from 72aed26f38a0f5a7be558eb44ba06d7739d77e72):
[ RUN      ] CygprofilePerfTest.CreateEntries_10_10000
*RESULT AddEntryCostPerCall: = 638.81 ns
[ RUN      ] CygprofilePerfTest.CreateEntries_100_10000
*RESULT AddEntryCostPerCall: = 242.751 ns
[ RUN      ] CygprofilePerfTest.CreateEntries_10_100000
*RESULT AddEntryCostPerCall: = 694.71 ns
[ RUN      ] CygprofilePerfTest.CreateEntries_100_1000000
*RESULT AddEntryCostPerCall: = 558.0389 ns

lightweight_cygprofile.cc:
[----------] 8 tests from CygprofilePerfTest
[ RUN      ] CygprofilePerfTest.RecordAddress_10_10000
*RESULT AddEntryCostPerCall_10_10000_1: = 5.9 ns
[       OK ] CygprofilePerfTest.RecordAddress_10_10000 (0 ms)
[ RUN      ] CygprofilePerfTest.RecordAddress_100_10000
*RESULT AddEntryCostPerCall_100_10000_1: = 4.746 ns
[       OK ] CygprofilePerfTest.RecordAddress_100_10000 (5 ms)
[ RUN      ] CygprofilePerfTest.RecordAddress_10_100000
*RESULT AddEntryCostPerCall_10_100000_1: = 5.975 ns
[       OK ] CygprofilePerfTest.RecordAddress_10_100000 (6 ms)
[ RUN      ] CygprofilePerfTest.RecordAddress_100_100000
*RESULT AddEntryCostPerCall_100_100000_1: = 5.0782 ns
[       OK ] CygprofilePerfTest.RecordAddress_100_100000 (51 ms)

Increasing the number of threads from 1 to 6:
[ RUN      ] CygprofilePerfTest.RecordAddress_1000_100000_2
*RESULT AddEntryCostPerCall_1000_100000_2: = 2.45617 ns
[       OK ] CygprofilePerfTest.RecordAddress_1000_100000_2 (246 ms)
[ RUN      ] CygprofilePerfTest.RecordAddress_1000_100000_3
*RESULT AddEntryCostPerCall_1000_100000_3: = 2.39735 ns
[       OK ] CygprofilePerfTest.RecordAddress_1000_100000_3 (240 ms)
[ RUN      ] CygprofilePerfTest.RecordAddress_1000_100000_4
*RESULT AddEntryCostPerCall_1000_100000_4: = 2.3979 ns
[       OK ] CygprofilePerfTest.RecordAddress_1000_100000_4 (240 ms)
[ RUN      ] CygprofilePerfTest.RecordAddress_1000_100000_6
*RESULT AddEntryCostPerCall_1000_100000_6: = 3.88468 ns
[       OK ] CygprofilePerfTest.RecordAddress_1000_100000_6 (390 ms)
[----------] 8 tests from CygprofilePerfTest (1181 ms total)

Overall, lightweight_cygprofile.cc is ~100x faster, even with
contention (~600ns to ~5ns per call).

Bug: 776702
Change-Id: I31fa5844a625443b252c18eebd4799be6d045141
Reviewed-on: https://chromium-review.googlesource.com/788953
Reviewed-by: agrieve <agrieve@chromium.org>
Reviewed-by: Egor Pasko <pasko@chromium.org>
Reviewed-by: Matthew Cary <mattcary@chromium.org>
Commit-Queue: Benoit L <lizeb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#519311}

CrOS-Libchrome-Original-Commit: 417487eaa0c0937760b2ccb33c964f1317b346d6
1 file changed
tree: 4b037bd90fdb64741a23e9efa3c74101b49e8c1b
  1. base/
  2. build/
  3. components/
  4. dbus/
  5. device/
  6. ipc/
  7. mojo/
  8. testing/
  9. third_party/
  10. ui/