1 | # -*- coding: utf-8 -*-
|
---|
2 | # $Id: valueunit.py 62484 2016-07-22 18:35:33Z vboxsync $
|
---|
3 |
|
---|
4 | """
|
---|
5 | Test Value Unit Definititions.
|
---|
6 |
|
---|
7 | This must correspond 1:1 with include/iprt/test.h and
|
---|
8 | include/VBox/VMMDevTesting.h.
|
---|
9 | """
|
---|
10 |
|
---|
11 | __copyright__ = \
|
---|
12 | """
|
---|
13 | Copyright (C) 2012-2016 Oracle Corporation
|
---|
14 |
|
---|
15 | This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
16 | available from http://www.virtualbox.org. This file is free software;
|
---|
17 | you can redistribute it and/or modify it under the terms of the GNU
|
---|
18 | General Public License (GPL) as published by the Free Software
|
---|
19 | Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
20 | VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
21 | hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
22 |
|
---|
23 | The contents of this file may alternatively be used under the terms
|
---|
24 | of the Common Development and Distribution License Version 1.0
|
---|
25 | (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
26 | VirtualBox OSE distribution, in which case the provisions of the
|
---|
27 | CDDL are applicable instead of those of the GPL.
|
---|
28 |
|
---|
29 | You may elect to license modified versions of this file under the
|
---|
30 | terms and conditions of either the GPL or the CDDL or both.
|
---|
31 | """
|
---|
32 | __version__ = "$Revision: 62484 $"
|
---|
33 |
|
---|
34 |
|
---|
35 |
|
---|
36 | ## @name Unit constants.
|
---|
37 | ## Used everywhere.
|
---|
38 | ## @note Using upper case here so we can copy, past and chop from the other
|
---|
39 | # headers.
|
---|
40 | ## @{
|
---|
41 | PCT = 0x01;
|
---|
42 | BYTES = 0x02;
|
---|
43 | BYTES_PER_SEC = 0x03;
|
---|
44 | KILOBYTES = 0x04;
|
---|
45 | KILOBYTES_PER_SEC = 0x05;
|
---|
46 | MEGABYTES = 0x06;
|
---|
47 | MEGABYTES_PER_SEC = 0x07;
|
---|
48 | PACKETS = 0x08;
|
---|
49 | PACKETS_PER_SEC = 0x09;
|
---|
50 | FRAMES = 0x0a;
|
---|
51 | FRAMES_PER_SEC = 0x0b;
|
---|
52 | OCCURRENCES = 0x0c;
|
---|
53 | OCCURRENCES_PER_SEC = 0x0d;
|
---|
54 | CALLS = 0x0e;
|
---|
55 | CALLS_PER_SEC = 0x0f;
|
---|
56 | ROUND_TRIP = 0x10;
|
---|
57 | SECS = 0x11;
|
---|
58 | MS = 0x12;
|
---|
59 | NS = 0x13;
|
---|
60 | NS_PER_CALL = 0x14;
|
---|
61 | NS_PER_FRAME = 0x15;
|
---|
62 | NS_PER_OCCURRENCE = 0x16;
|
---|
63 | NS_PER_PACKET = 0x17;
|
---|
64 | NS_PER_ROUND_TRIP = 0x18;
|
---|
65 | INSTRS = 0x19;
|
---|
66 | INSTRS_PER_SEC = 0x1a;
|
---|
67 | NONE = 0x1b;
|
---|
68 | PP1K = 0x1c;
|
---|
69 | PP10K = 0x1d;
|
---|
70 | PPM = 0x1e;
|
---|
71 | PPB = 0x1f;
|
---|
72 | END = 0x20;
|
---|
73 | ## @}
|
---|
74 |
|
---|
75 |
|
---|
76 | ## Translate constant to string.
|
---|
77 | g_asNames = \
|
---|
78 | [
|
---|
79 | 'invalid', # 0
|
---|
80 | '%',
|
---|
81 | 'bytes',
|
---|
82 | 'bytes/s',
|
---|
83 | 'KiB',
|
---|
84 | 'KiB/s',
|
---|
85 | 'MiB',
|
---|
86 | 'MiB/s',
|
---|
87 | 'packets',
|
---|
88 | 'packets/s',
|
---|
89 | 'frames',
|
---|
90 | 'frames/s',
|
---|
91 | 'occurrences',
|
---|
92 | 'occurrences/s',
|
---|
93 | 'calls',
|
---|
94 | 'calls/s',
|
---|
95 | 'roundtrips',
|
---|
96 | 's',
|
---|
97 | 'ms',
|
---|
98 | 'ns',
|
---|
99 | 'ns/call',
|
---|
100 | 'ns/frame',
|
---|
101 | 'ns/occurrences',
|
---|
102 | 'ns/packet',
|
---|
103 | 'ns/roundtrips',
|
---|
104 | 'ins',
|
---|
105 | 'ins/s',
|
---|
106 | '', # none
|
---|
107 | 'pp1k',
|
---|
108 | 'pp10k',
|
---|
109 | 'ppm',
|
---|
110 | 'ppb',
|
---|
111 | ];
|
---|
112 | assert g_asNames[PP1K] == 'pp1k';
|
---|
113 |
|
---|
114 |
|
---|
115 | ## Translation table for XML -> number.
|
---|
116 | g_kdNameToConst = \
|
---|
117 | {
|
---|
118 | 'KB': KILOBYTES,
|
---|
119 | 'KB/s': KILOBYTES_PER_SEC,
|
---|
120 | 'MB': MEGABYTES,
|
---|
121 | 'MB/s': MEGABYTES_PER_SEC,
|
---|
122 | 'occurrences': OCCURRENCES,
|
---|
123 | 'occurrences/s': OCCURRENCES_PER_SEC,
|
---|
124 |
|
---|
125 | };
|
---|
126 | for i in range(1, len(g_asNames)):
|
---|
127 | g_kdNameToConst[g_asNames[i]] = i;
|
---|
128 |
|
---|