summaryrefslogtreecommitdiff
path: root/src/testlib/qbenchmarkmetric.cpp
blob: 8af8a5f0fbddc8fd65330f6bfba19219c3770c78 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtTest module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 3 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL3 included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 3 requirements
** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 2.0 or (at your option) the GNU General
** Public license version 3 or any later version approved by the KDE Free
** Qt Foundation. The licenses are as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
** https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/

#include <QtTest/private/qbenchmarkmetric_p.h>

/*!
  \enum QTest::QBenchmarkMetric
  \since 4.7

  This enum lists all the things that can be benchmarked.

  \value FramesPerSecond        Frames per second
  \value BitsPerSecond          Bits per second
  \value BytesPerSecond         Bytes per second
  \value WalltimeMilliseconds   Clock time in milliseconds
  \value WalltimeNanoseconds    Clock time in nanoseconds
  \value BytesAllocated         Memory usage in bytes
  \value Events                 Event count
  \value CPUTicks               CPU time
  \value CPUMigrations          Process migrations between CPUs
  \value CPUCycles              CPU cycles
  \value BusCycles              Bus cycles
  \value StalledCycles          Cycles stalled
  \value InstructionReads       Instruction reads
  \value Instructions           Instructions executed
  \value BranchInstructions     Branch-type instructions
  \value BranchMisses           Branch instructions that were mispredicted
  \value CacheReferences        Cache accesses of any type
  \value CacheMisses            Cache misses of any type
  \value CacheReads             Cache reads / loads
  \value CacheReadMisses        Cache read / load misses
  \value CacheWrites            Cache writes / stores
  \value CacheWriteMisses       Cache write / store misses
  \value CachePrefetches        Cache prefetches
  \value CachePrefetchMisses    Cache prefetch misses
  \value ContextSwitches        Context switches
  \value PageFaults             Page faults of any type
  \value MinorPageFaults        Minor page faults
  \value MajorPageFaults        Major page faults
  \value AlignmentFaults        Faults caused due to misalignment
  \value EmulationFaults        Faults that needed software emulation

  \sa QTest::benchmarkMetricName(), QTest::benchmarkMetricUnit()

  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.
 */

/*!
  \since 4.7
  Returns the enum value \a metric as a character string.
 */
const char * QTest::benchmarkMetricName(QBenchmarkMetric metric)
{
    switch (metric) {
    case FramesPerSecond:
        return "FramesPerSecond";
    case BitsPerSecond:
        return "BitsPerSecond";
    case BytesPerSecond:
        return "BytesPerSecond";
    case WalltimeMilliseconds:
        return "WalltimeMilliseconds";
    case Events:
        return "Events";
    case CPUTicks:
        return "CPUTicks";
    case CPUMigrations:
        return "CPUMigrations";
    case CPUCycles:
        return "CPUCycles";
    case BusCycles:
        return "BusCycles";
    case StalledCycles:
        return "StalledCycles";
    case InstructionReads:
        return "InstructionReads";
    case Instructions:
        return "Instructions";
    case WalltimeNanoseconds:
        return "WalltimeNanoseconds";
    case BytesAllocated:
        return "BytesAllocated";
    case BranchInstructions:
        return "BranchInstructions";
    case BranchMisses:
        return "BranchMisses";
    case CacheReferences:
        return "CacheReferences";
    case CacheReads:
        return "CacheReads";
    case CacheWrites:
        return "CacheWrites";
    case CachePrefetches:
        return "CachePrefetches";
    case CacheMisses:
        return "CacheMisses";
    case CacheReadMisses:
        return "CacheReadMisses";
    case CacheWriteMisses:
        return "CacheWriteMisses";
    case CachePrefetchMisses:
        return "CachePrefetchMisses";
    case ContextSwitches:
        return "ContextSwitches";
    case PageFaults:
        return "PageFaults";
    case MinorPageFaults:
        return "MinorPageFaults";
    case MajorPageFaults:
        return "MajorPageFaults";
    case AlignmentFaults:
        return "AlignmentFaults";
    case EmulationFaults:
        return "EmulationFaults";
    default:
        return "";
    }
};

/*!
  \since 4.7
  Retuns the units of measure for the specified \a metric.
 */
const char * QTest::benchmarkMetricUnit(QBenchmarkMetric metric)
{
    switch (metric) {
    case FramesPerSecond:
        return "fps";
    case BitsPerSecond:
        return "bits/s";
    case BytesPerSecond:
        return "bytes/s";
    case WalltimeMilliseconds:
        return "msecs";
    case Events:
        return "events";
    case CPUTicks:
        return "CPU ticks";
    case CPUMigrations:
        return "CPU migrations";
    case CPUCycles:
        return "CPU cycles";
    case BusCycles:
        return "bus cycles";
    case StalledCycles:
        return "stalled cycles";
    case InstructionReads:
        return "instruction reads";
    case Instructions:
        return "instructions";
    case WalltimeNanoseconds:
        return "nsecs";
    case BytesAllocated:
        return "bytes";
    case BranchInstructions:
        return "branch instructions";
    case BranchMisses:
        return "branch misses";
    case CacheReferences:
        return "cache references";
    case CacheReads:
        return "cache loads";
    case CacheWrites:
        return "cache stores";
    case CachePrefetches:
        return "cache prefetches";
    case CacheMisses:
        return "cache misses";
    case CacheReadMisses:
        return "cache load misses";
    case CacheWriteMisses:
        return "cache store misses";
    case CachePrefetchMisses:
        return "cache prefetch misses";
    case ContextSwitches:
        return "context switches";
    case PageFaults:
        return "page faults";
    case MinorPageFaults:
        return "minor page faults";
    case MajorPageFaults:
        return "major page faults";
    case AlignmentFaults:
        return "alignment faults";
    case EmulationFaults:
        return "emulation faults";
    default:
        return "";
    }
}