1 | /* $Id: bs3-timing-1-exe.c 89151 2021-05-19 00:58:58Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * BS3Kit - bs3-timing-1, regular executable version of the TSC test.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2007-2021 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | *
|
---|
17 | * The contents of this file may alternatively be used under the terms
|
---|
18 | * of the Common Development and Distribution License Version 1.0
|
---|
19 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
20 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
21 | * CDDL are applicable instead of those of the GPL.
|
---|
22 | *
|
---|
23 | * You may elect to license modified versions of this file under the
|
---|
24 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
25 | */
|
---|
26 |
|
---|
27 |
|
---|
28 | /*********************************************************************************************************************************
|
---|
29 | * Header Files *
|
---|
30 | *********************************************************************************************************************************/
|
---|
31 | #include <iprt/assert.h>
|
---|
32 | #include <iprt/errcore.h>
|
---|
33 | #include <iprt/getopt.h>
|
---|
34 | #include <iprt/initterm.h>
|
---|
35 | #include <iprt/message.h>
|
---|
36 | #include <iprt/stream.h>
|
---|
37 | #include <iprt/string.h>
|
---|
38 | #include <iprt/time.h>
|
---|
39 |
|
---|
40 | /* Fake bs3kit.h bits: */
|
---|
41 | #define Bs3TestNow RTTimeNanoTS
|
---|
42 | #define Bs3TestPrintf RTPrintf
|
---|
43 | #define Bs3TestFailedF RTMsgError
|
---|
44 | #define Bs3MemZero RT_BZERO
|
---|
45 | #define BS3_DECL(t) t
|
---|
46 |
|
---|
47 | #define STANDALONE_EXECUTABLE
|
---|
48 | #include "bs3-timing-1-32.c32"
|
---|
49 |
|
---|
50 |
|
---|
51 | int main(int argc, char **argv)
|
---|
52 | {
|
---|
53 | /*
|
---|
54 | * Parse arguments.
|
---|
55 | */
|
---|
56 | static const RTGETOPTDEF s_aOptions[] =
|
---|
57 | {
|
---|
58 | { "--loops", 'l', RTGETOPT_REQ_UINT32 },
|
---|
59 | { "--seconds", 's', RTGETOPT_REQ_UINT32 },
|
---|
60 | { "--min-history", 'm', RTGETOPT_REQ_UINT32 },
|
---|
61 | { "--quiet", 'q', RTGETOPT_REQ_NOTHING },
|
---|
62 | { "--verbose", 'v', RTGETOPT_REQ_NOTHING },
|
---|
63 | };
|
---|
64 | uint32_t cLoops = 5;
|
---|
65 | uint32_t cSecs = 10;
|
---|
66 | unsigned uVerbosity = 1;
|
---|
67 | unsigned iMinHistory = 17;
|
---|
68 |
|
---|
69 | RTGETOPTSTATE GetState;
|
---|
70 | RTGETOPTUNION ValueUnion;
|
---|
71 |
|
---|
72 | int rc = RTR3InitExe(argc, &argv, 0);
|
---|
73 | if (RT_FAILURE(rc))
|
---|
74 | return RTMsgInitFailure(rc);
|
---|
75 |
|
---|
76 | rc = RTGetOptInit(&GetState, argc, argv, s_aOptions, RT_ELEMENTS(s_aOptions), 1, RTGETOPTINIT_FLAGS_OPTS_FIRST);
|
---|
77 | AssertRC(rc);
|
---|
78 | while ((rc = RTGetOpt(&GetState, &ValueUnion)) != 0)
|
---|
79 | {
|
---|
80 | switch (rc)
|
---|
81 | {
|
---|
82 | case 'l':
|
---|
83 | cLoops = ValueUnion.u32;
|
---|
84 | break;
|
---|
85 | case 'm':
|
---|
86 | iMinHistory = ValueUnion.u32;
|
---|
87 | break;
|
---|
88 | case 's':
|
---|
89 | cSecs = ValueUnion.u32;
|
---|
90 | if (cSecs == 0 || cSecs > RT_SEC_1DAY / 2)
|
---|
91 | return RTMsgErrorExitFailure("Seconds value is out of range: %u (min 1, max %u)", cSecs, RT_SEC_1DAY / 2);
|
---|
92 | break;
|
---|
93 | case 'q':
|
---|
94 | uVerbosity = 0;
|
---|
95 | break;
|
---|
96 | case 'v':
|
---|
97 | uVerbosity++;
|
---|
98 | break;
|
---|
99 | case 'V':
|
---|
100 | RTPrintf("v0.1.0\n");
|
---|
101 | return RTEXITCODE_SUCCESS;
|
---|
102 | case 'h':
|
---|
103 | RTPrintf("usage: %Rbn [-q|-v] [-l <iterations>] [-s <seconds-per-iteration>] [-m <log2-big-gap>]\n", argv[0]);
|
---|
104 | return RTEXITCODE_SUCCESS;
|
---|
105 | default:
|
---|
106 | return RTGetOptPrintError(rc, &ValueUnion);
|
---|
107 | }
|
---|
108 | }
|
---|
109 |
|
---|
110 | /*
|
---|
111 | * Run the test.
|
---|
112 | */
|
---|
113 | bs3Timing1_Tsc_Driver(cLoops, cSecs, uVerbosity, iMinHistory);
|
---|
114 | return RTEXITCODE_SUCCESS;
|
---|
115 | }
|
---|
116 |
|
---|