summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMilian Wolff <milian.wolff@kdab.com>2017-02-28 11:32:31 +0100
committerMilian Wolff <milian.wolff@kdab.com>2017-02-28 16:16:19 +0000
commit25e9054364a120a8da0346bb6fe0df401fe7bbb4 (patch)
treed188268c00645e3a043692aa04d76f747490169d /tests
parentc8df742045e14be280e867fa9c6984cfc51e02a2 (diff)
Add benchmarks for various usage scenarios of the elfmap
Basically, there are three general scenarios I can envision: - disjunct elf mappings - overlapping elf mappings - expanding elf mappings (e.g. for heap/anon sections) This patch adds benchmarks for all three of these cases. The results from my machine are as follows, and clearly show quadratic behavior, as well as a factor of 2 overhead when encoutering overlapping elf mappings: PASS : TestElfMap::benchRegisterElfDisjunct(10) RESULT : TestElfMap::benchRegisterElfDisjunct():"10": 0.0016 msecs per iteration (total: 55, iterations: 32768) PASS : TestElfMap::benchRegisterElfDisjunct(100) RESULT : TestElfMap::benchRegisterElfDisjunct():"100": 0.037 msecs per iteration (total: 77, iterations: 2048) PASS : TestElfMap::benchRegisterElfDisjunct(1000) RESULT : TestElfMap::benchRegisterElfDisjunct():"1000": 3.6 msecs per iteration (total: 59, iterations: 16) PASS : TestElfMap::benchRegisterElfDisjunct(2000) RESULT : TestElfMap::benchRegisterElfDisjunct():"2000": 19 msecs per iteration (total: 77, iterations: 4) PASS : TestElfMap::benchRegisterElfOverlapping(10) RESULT : TestElfMap::benchRegisterElfOverlapping():"10": 0.0037 msecs per iteration (total: 61, iterations: 16384) PASS : TestElfMap::benchRegisterElfOverlapping(100) RESULT : TestElfMap::benchRegisterElfOverlapping():"100": 0.083 msecs per iteration (total: 85, iterations: 1024) PASS : TestElfMap::benchRegisterElfOverlapping(1000) RESULT : TestElfMap::benchRegisterElfOverlapping():"1000": 9.2 msecs per iteration (total: 74, iterations: 8) PASS : TestElfMap::benchRegisterElfOverlapping(2000) RESULT : TestElfMap::benchRegisterElfOverlapping():"2000": 33.7 msecs per iteration (total: 135, iterations: 4) PASS : TestElfMap::benchRegisterElfExpanding(10) RESULT : TestElfMap::benchRegisterElfExpanding():"10": 0.0018 msecs per iteration (total: 61, iterations: 32768) PASS : TestElfMap::benchRegisterElfExpanding(100) RESULT : TestElfMap::benchRegisterElfExpanding():"100": 0.042 msecs per iteration (total: 88, iterations: 2048) PASS : TestElfMap::benchRegisterElfExpanding(1000) RESULT : TestElfMap::benchRegisterElfExpanding():"1000": 4.1 msecs per iteration (total: 67, iterations: 16) PASS : TestElfMap::benchRegisterElfExpanding(2000) RESULT : TestElfMap::benchRegisterElfExpanding():"2000": 21 msecs per iteration (total: 84, iterations: 4) Change-Id: I57eb0c692a400e60e370b09ca63c499f8cc8a05a Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/elfmap/tst_elfmap.cpp66
1 files changed, 66 insertions, 0 deletions
diff --git a/tests/auto/elfmap/tst_elfmap.cpp b/tests/auto/elfmap/tst_elfmap.cpp
index e702a1d..067afa2 100644
--- a/tests/auto/elfmap/tst_elfmap.cpp
+++ b/tests/auto/elfmap/tst_elfmap.cpp
@@ -169,6 +169,72 @@ private slots:
QTest::newRow("normal-no-files") << false << false << false;
QTest::newRow("reversed-no-files") << true << false << false;
}
+
+ void benchRegisterElfDisjunct()
+ {
+ QFETCH(int, numElfMaps);
+ const quint64 ADDR_STEP = 1024;
+ const quint64 MAX_ADDR = ADDR_STEP * numElfMaps;
+ const quint64 LEN = 1024;
+ QBENCHMARK {
+ PerfElfMap map;
+ quint64 time = 0;
+ for (quint64 addr = 0; addr < MAX_ADDR; addr += ADDR_STEP) {
+ map.registerElf(addr, LEN, 0, time++, {});
+ }
+ }
+ }
+
+ void benchRegisterElfDisjunct_data()
+ {
+ QTest::addColumn<int>("numElfMaps");
+ QTest::newRow("10") << 10;
+ QTest::newRow("100") << 100;
+ QTest::newRow("1000") << 1000;
+ QTest::newRow("2000") << 2000;
+ }
+
+ void benchRegisterElfOverlapping()
+ {
+ QFETCH(int, numElfMaps);
+ const quint64 ADDR_STEP = 1024;
+ const quint64 MAX_ADDR = ADDR_STEP * numElfMaps;
+ quint64 len = MAX_ADDR;
+ QBENCHMARK {
+ PerfElfMap map;
+ quint64 time = 0;
+ for (quint64 addr = 0; addr < MAX_ADDR; addr += ADDR_STEP, len -= ADDR_STEP) {
+ map.registerElf(addr, len, 0, time++, {});
+ }
+ }
+ }
+
+ void benchRegisterElfOverlapping_data()
+ {
+ benchRegisterElfDisjunct_data();
+ }
+
+
+ void benchRegisterElfExpanding()
+ {
+ QFETCH(int, numElfMaps);
+ const quint64 ADDR = 0;
+ const quint64 LEN_STEP = 1024;
+ const quint64 MAX_LEN = LEN_STEP * numElfMaps;
+ QBENCHMARK {
+ PerfElfMap map;
+ quint64 time = 0;
+ for (quint64 len = LEN_STEP; len <= MAX_LEN; len += LEN_STEP) {
+ map.registerElf(ADDR, len, 0, time++, {});
+ }
+ }
+ }
+
+ void benchRegisterElfExpanding_data()
+ {
+ benchRegisterElfDisjunct_data();
+ }
+
};
QTEST_GUILESS_MAIN(TestElfMap)