-
Notifications
You must be signed in to change notification settings - Fork 0
/
Speed.h
executable file
·116 lines (96 loc) · 3.95 KB
/
Speed.h
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
/***************************************************************
*
* C file: speed.h... for cpuinf32 DLL
*
* This program has been developed by Intel Corporation.
* You have Intel's permission to incorporate this code
* into your product, royalty free. Intel has various
* intellectual property rights which it may assert under
* certain circumstances, such as if another manufacturer's
* processor mis-identifies itself as being "GenuineIntel"
* when the CPUID instruction is executed.
*
* Intel specifically disclaims all warranties, express or
* implied, and all liability, including consequential and
* other indirect damages, for the use of this code,
* including liability for infringement of any proprietary
* rights, and including the warranties of merchantability
* and fitness for a particular purpose. Intel does not
* assume any responsibility for any errors which may
* appear in this code nor any responsibility to update it.
*
* * Other brands and names are the property of their respective
* owners.
*
* Copyright (c) 1995, Intel Corporation. All rights reserved.
***************************************************************/
#ifndef speed_h
#define speed_h
// CONSTANT DEFINITIONS ////////////////////////////////////////
#define CLONE_MASK 0x8000 // Mask to be 'OR'ed with proc-
#define MAXCLOCKS 150 // Maximum number of cycles per
// BSF instruction
// ACCURACY AFFECTING CONSTANTS ////////////////////////////
#define ITERATIONS 4000 // Number of times to repeat BSF
// instruction in samplings.
// Initially set to 4000.
#define MAX_TRIES 20 // Maximum number of samplings
// to allow before giving up
// and returning current
// average. Initially set to
// 20.
#define TOLERANCE 1 // Number of MHz to allow
// samplings to deviate from
// average of samplings.
// Initially set to 2.
#define SAMPLINGS 10 // Number of BSF sequence
// samplings to make.
// Initially set to 10.
// VARIABLE STRUCTURE DEFINITIONS //////////////////////////////
struct FREQ_INFO
{
unsigned long in_cycles; // Internal clock cycles during
// test
unsigned long ex_ticks; // Microseconds elapsed during
// test
unsigned long raw_freq; // Raw frequency of CPU in MHz
unsigned long norm_freq; // Normalized frequency of CPU
// in MHz.
};
typedef unsigned short ushort;
typedef unsigned long ulong;
/***************************************************************
* BOOL WINAPI DllMain()
*
* Inputs: hDLL - handle of DLL
* dwReason - indicates why DLL called
* lpReserved - reserved
*
* Return Value: TRUE (always)
***************************************************************/
BOOL WINAPI DllMain (HINSTANCE hDLL,
DWORD dwReason,
LPVOID lpReserved);
/***************************************************************
* CpuSpeed() -- Return the raw clock rate of the host CPU.
*
* Inputs:
* clocks: NULL: Use default value for number of cycles
* per BSF instruction.
* Positive Integer: Use clocks value for number
* of cycles per BSF instruction.
* -1: Use CMos timer to calculate speed
* (May not work for WinNT.
*
* Returns:
* If error then return all zeroes in FREQ_INFO structure
* Else return FREQ_INFO structure containing calculated
* clock frequency, normalized clock frequency, number of
* clock cycles during test sampling, and the number of
* microseconds elapsed during the sampling.
***************************************************************/
struct FREQ_INFO cpuspeed(int clocks);
unsigned long cpurawspeed(int clocks);
unsigned long cpunormspeed(int clocks);
unsigned long ProcessorCount();
#endif speed_h