1 | // Copyright (C) 2016 The Qt Company Ltd. |
2 | // Copyright (C) 2016 Intel Corporation. |
3 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
4 | |
5 | #include <QtTest/private/qbenchmarkmetric_p.h> |
6 | |
7 | QT_BEGIN_NAMESPACE |
8 | |
9 | namespace QTest { |
10 | |
11 | struct QBenchmarkMetricKey { |
12 | int metric; |
13 | const char * name; |
14 | const char * unit; |
15 | }; |
16 | |
17 | static const QBenchmarkMetricKey entries[] = { |
18 | { .metric: FramesPerSecond, .name: "FramesPerSecond" , .unit: "fps" }, |
19 | { .metric: BitsPerSecond, .name: "BitsPerSecond" , .unit: "bits/s" }, |
20 | { .metric: BytesPerSecond, .name: "BytesPerSecond" , .unit: "bytes/s" }, |
21 | { .metric: WalltimeMilliseconds, .name: "WalltimeMilliseconds" , .unit: "msecs" }, |
22 | { .metric: CPUTicks, .name: "CPUTicks" , .unit: "CPU ticks" }, |
23 | { .metric: InstructionReads, .name: "InstructionReads" , .unit: "instruction reads" }, |
24 | { .metric: Events, .name: "Events" , .unit: "events" }, |
25 | { .metric: WalltimeNanoseconds, .name: "WalltimeNanoseconds" , .unit: "nsecs" }, |
26 | { .metric: BytesAllocated, .name: "BytesAllocated" , .unit: "bytes" }, |
27 | { .metric: CPUMigrations, .name: "CPUMigrations" , .unit: "CPU migrations" }, |
28 | { .metric: CPUCycles, .name: "CPUCycles" , .unit: "CPU cycles" }, |
29 | { .metric: BusCycles, .name: "BusCycles" , .unit: "bus cycles" }, |
30 | { .metric: StalledCycles, .name: "StalledCycles" , .unit: "stalled cycles" }, |
31 | { .metric: Instructions, .name: "Instructions" , .unit: "instructions" }, |
32 | { .metric: BranchInstructions, .name: "BranchInstructions" , .unit: "branch instructions" }, |
33 | { .metric: BranchMisses, .name: "BranchMisses" , .unit: "branch misses" }, |
34 | { .metric: CacheReferences, .name: "CacheReferences" , .unit: "cache references" }, |
35 | { .metric: CacheReads, .name: "CacheReads" , .unit: "cache loads" }, |
36 | { .metric: CacheWrites, .name: "CacheWrites" , .unit: "cache stores" }, |
37 | { .metric: CachePrefetches, .name: "CachePrefetches" , .unit: "cache prefetches" }, |
38 | { .metric: CacheMisses, .name: "CacheMisses" , .unit: "cache misses" }, |
39 | { .metric: CacheReadMisses, .name: "CacheReadMisses" , .unit: "cache load misses" }, |
40 | { .metric: CacheWriteMisses, .name: "CacheWriteMisses" , .unit: "cache store misses" }, |
41 | { .metric: CachePrefetchMisses, .name: "CachePrefetchMisses" , .unit: "cache prefetch misses" }, |
42 | { .metric: ContextSwitches, .name: "ContextSwitches" , .unit: "context switches" }, |
43 | { .metric: PageFaults, .name: "PageFaults" , .unit: "page faults" }, |
44 | { .metric: MinorPageFaults, .name: "MinorPageFaults" , .unit: "minor page faults" }, |
45 | { .metric: MajorPageFaults, .name: "MajorPageFaults" , .unit: "major page faults" }, |
46 | { .metric: AlignmentFaults, .name: "AlignmentFaults" , .unit: "alignment faults" }, |
47 | { .metric: EmulationFaults, .name: "EmulationFaults" , .unit: "emulation faults" }, |
48 | { .metric: RefCPUCycles, .name: "RefCPUCycles" , .unit: "Reference CPU cycles" }, |
49 | }; |
50 | static const int NumEntries = sizeof(entries) / sizeof(entries[0]); |
51 | |
52 | } |
53 | |
54 | /*! |
55 | \enum QTest::QBenchmarkMetric |
56 | \since 4.7 |
57 | |
58 | This enum lists all the things that can be benchmarked. |
59 | |
60 | \value FramesPerSecond Frames per second |
61 | \value BitsPerSecond Bits per second |
62 | \value BytesPerSecond Bytes per second |
63 | \value WalltimeMilliseconds Clock time in milliseconds |
64 | \value WalltimeNanoseconds Clock time in nanoseconds |
65 | \value BytesAllocated Memory usage in bytes |
66 | \value Events Event count |
67 | \value CPUTicks CPU time |
68 | \value CPUMigrations Process migrations between CPUs |
69 | \value CPUCycles CPU cycles |
70 | \value RefCPUCycles Reference CPU cycles |
71 | \value BusCycles Bus cycles |
72 | \value StalledCycles Cycles stalled |
73 | \value InstructionReads Instruction reads |
74 | \value Instructions Instructions executed |
75 | \value BranchInstructions Branch-type instructions |
76 | \value BranchMisses Branch instructions that were mispredicted |
77 | \value CacheReferences Cache accesses of any type |
78 | \value CacheMisses Cache misses of any type |
79 | \value CacheReads Cache reads / loads |
80 | \value CacheReadMisses Cache read / load misses |
81 | \value CacheWrites Cache writes / stores |
82 | \value CacheWriteMisses Cache write / store misses |
83 | \value CachePrefetches Cache prefetches |
84 | \value CachePrefetchMisses Cache prefetch misses |
85 | \value ContextSwitches Context switches |
86 | \value PageFaults Page faults of any type |
87 | \value MinorPageFaults Minor page faults |
88 | \value MajorPageFaults Major page faults |
89 | \value AlignmentFaults Faults caused due to misalignment |
90 | \value EmulationFaults Faults that needed software emulation |
91 | |
92 | \sa QTest::benchmarkMetricName(), QTest::benchmarkMetricUnit() |
93 | |
94 | Note that \c WalltimeNanoseconds and \c BytesAllocated are |
95 | only provided for use via \l setBenchmarkResult(), and results |
96 | in those metrics are not able to be provided automatically |
97 | by the QTest framework. |
98 | */ |
99 | |
100 | /*! |
101 | \since 4.7 |
102 | Returns the enum value \a metric as a character string. |
103 | */ |
104 | const char * QTest::benchmarkMetricName(QBenchmarkMetric metric) |
105 | { |
106 | if (unsigned(metric) < unsigned(QTest::NumEntries)) |
107 | return entries[metric].name; |
108 | |
109 | return "" ; |
110 | } |
111 | |
112 | /*! |
113 | \since 4.7 |
114 | Returns the units of measure for the specified \a metric. |
115 | */ |
116 | const char * QTest::benchmarkMetricUnit(QBenchmarkMetric metric) |
117 | { |
118 | if (unsigned(metric) < unsigned(QTest::NumEntries)) |
119 | return entries[metric].unit; |
120 | |
121 | return "" ; |
122 | } |
123 | |
124 | QT_END_NAMESPACE |
125 | |