Add new benchmark metrics to testlib
authorChris Adams <christopher.adams@nokia.com>
Wed, 9 May 2012 06:43:53 +0000 (16:43 +1000)
committerQt by Nokia <qt-info@nokia.com>
Wed, 20 Jun 2012 22:58:12 +0000 (00:58 +0200)
QElapsedTimer provides nanosecond-resolution elapsed timing, which
allows for finer granularity benchmark reporting.  Also, clients
may also wish to benchmark the memory usage of a particular component,
but no metric currently exists which matches that requirement.

This commit adds the WalltimeNanoseconds and BytesAllocated metrics
to meet these needs.  It is intended for manual use by clients via
setBenchmarkResult() only.

Change-Id: Ib37ada374e265c857eda02d047d51d436618e4a7
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
Reviewed-by: Jason McDonald <jason.mcdonald@nokia.com>
src/testlib/qbenchmarkmetric.cpp
src/testlib/qbenchmarkmetric.h

index e48375c..bebd131 100644 (file)
   \value CPUTicks               CPU time
   \value InstructionReads       Instruction reads
   \value Events                 Event count
+  \value WalltimeNanoseconds    Clock time in nanoseconds
+  \value BytesAllocated         Memory usage in bytes
+
+  Note that \c WalltimeNanoseconds and \c BytesAllocated are
+  only provided for use via \l setBenchmarkResult(), and results
+  in those metrics are not able to be provided automatically
+  by the QTest framework.
 
   \sa QTest::benchmarkMetricName(), QTest::benchmarkMetricUnit()
 
@@ -81,6 +88,10 @@ const char * QTest::benchmarkMetricName(QBenchmarkMetric metric)
         return "InstructionReads";
     case Events:
         return "Events";
+    case WalltimeNanoseconds:
+        return "WalltimeNanoseconds";
+    case BytesAllocated:
+        return "BytesAllocated";
     default:
         return "";
     }
@@ -108,6 +119,10 @@ const char * QTest::benchmarkMetricUnit(QBenchmarkMetric metric)
         return "instruction reads";
     case Events:
         return "events";
+    case WalltimeNanoseconds:
+        return "nsecs";
+    case BytesAllocated:
+        return "bytes";
     default:
         return "";
     }
index e8514a4..a95cdea 100644 (file)
@@ -58,7 +58,9 @@ enum QBenchmarkMetric {
     WalltimeMilliseconds,
     CPUTicks,
     InstructionReads,
-    Events
+    Events,
+    WalltimeNanoseconds,
+    BytesAllocated
 };
 
 }