From af437047a2d849d19f8de01b5ecfb685f813d6a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lund=20Martsum?= Date: Sun, 28 Oct 2012 15:36:11 +0100 Subject: QMap - improve QMap stl-map ctor We can insert directly on the most left-most Node. We always enforce an insert here (unlike the insert call), but that is not a problem since the keys in a std::map are unique. Change-Id: Ib409b90ffc57a5a43dab4a4b08d34f6fdabd057f Reviewed-by: Lars Knoll --- tests/benchmarks/corelib/tools/qmap/main.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'tests/benchmarks') diff --git a/tests/benchmarks/corelib/tools/qmap/main.cpp b/tests/benchmarks/corelib/tools/qmap/main.cpp index 4d9833b7a1..c11e54ff1d 100644 --- a/tests/benchmarks/corelib/tools/qmap/main.cpp +++ b/tests/benchmarks/corelib/tools/qmap/main.cpp @@ -62,6 +62,8 @@ private slots: void iteration(); void toStdMap(); void iterator_begin(); + + void ctorStdMap(); }; @@ -189,6 +191,19 @@ void tst_QMap::iterator_begin() } } +void tst_QMap::ctorStdMap() +{ + std::map map; + for (int i = 0; i < 100000; ++i) + map.insert(std::pair(i, i)); + + QBENCHMARK { + QMap qmap(map); + qmap.constBegin(); + } +} + + QTEST_MAIN(tst_QMap) #include "main.moc" -- cgit v1.2.3