summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2013-06-18 12:47:38 -0700
committerColin Cross <ccross@android.com>2013-06-18 12:55:52 -0700
commit7d90cfa6b5b49abb2123b069b81e0b9f4eba6432 (patch)
treea63015694bc84cd2ea0686b84bf4f447ab9dbea9 /tests
parent977a33137d2be0093f474055f839cf665b82b588 (diff)
downloadbionic-7d90cfa6b5b49abb2123b069b81e0b9f4eba6432.zip
bionic-7d90cfa6b5b49abb2123b069b81e0b9f4eba6432.tar.gz
bionic-7d90cfa6b5b49abb2123b069b81e0b9f4eba6432.tar.bz2
bionic: change properties benchmarks to read a single property
The properties benchmarks were reading n properties from a property area with n properties in it, which was making it hard to compare the time between runs of different sizes. Change the benchmark to read a random property per iteration so the numbers between runs are comparable. Change-Id: Ib1648ce0948d9038fce76d209608427376cfb8da
Diffstat (limited to 'tests')
-rw-r--r--tests/property_benchmark.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/tests/property_benchmark.cpp b/tests/property_benchmark.cpp
index dbd11ad..5acd06c 100644
--- a/tests/property_benchmark.cpp
+++ b/tests/property_benchmark.cpp
@@ -87,12 +87,12 @@ static void BM_property_get(int iters, int nprops)
LocalPropertyTestState pa(nprops);
char value[PROP_VALUE_MAX];
+ srandom(iters * nprops);
+
StartBenchmarkTiming();
for (int i = 0; i < iters; i++) {
- for (int j = 0; j < nprops; j++) {
- __system_property_get(pa.names[j], value);
- }
+ __system_property_get(pa.names[random() % nprops], value);
}
StopBenchmarkTiming();
}
@@ -104,12 +104,12 @@ static void BM_property_find(int iters, int nprops)
LocalPropertyTestState pa(nprops);
+ srandom(iters * nprops);
+
StartBenchmarkTiming();
for (int i = 0; i < iters; i++) {
- for (int j = 0; j < nprops; j++) {
- __system_property_find(pa.names[j]);
- }
+ __system_property_find(pa.names[random() % nprops]);
}
StopBenchmarkTiming();
}