27 |
|
|
28 |
unsigned long long Profiler::profilingSamples = 0; |
unsigned long long Profiler::profilingSamples = 0; |
29 |
unsigned long long Profiler::profilingTime = 0; |
unsigned long long Profiler::profilingTime = 0; |
30 |
unsigned long long Profiler::ticksPerSecond = 0; |
double Profiler::tsPerSecond = 0; |
31 |
|
bool Profiler::bEnabled = false; |
32 |
|
|
33 |
void Profiler::Calibrate( void ) |
void Profiler::Calibrate( void ) |
34 |
{ |
{ |
35 |
clock_t start_time = clock(); |
clock_t start_time = clock(); |
36 |
unsigned long long start_clocks = Stamp(); |
RTMath::time_stamp_t start_clocks = Stamp(); |
37 |
volatile int a = 1; |
volatile int a = 1; |
38 |
volatile int b = 1; |
volatile int b = 1; |
39 |
for (volatile int i = 0; i < 100000000; i++) |
for (volatile int i = 0; i < 100000000; i++) |
41 |
a += b; |
a += b; |
42 |
} |
} |
43 |
clock_t stop_time = clock(); |
clock_t stop_time = clock(); |
44 |
unsigned long long stop_clocks = Stamp(); |
RTMath::time_stamp_t stop_clocks = Stamp(); |
45 |
unsigned int diff_ticks = (unsigned int) (stop_clocks - start_clocks); |
double diff_ticks = (stop_clocks - start_clocks); |
46 |
double diff_time = ((stop_time - start_time) / (double(CLOCKS_PER_SEC))); |
double diff_time = ((stop_time - start_time) / (double(CLOCKS_PER_SEC))); |
47 |
ticksPerSecond = (unsigned long long)(double(diff_ticks) / diff_time); |
tsPerSecond = diff_ticks / diff_time; |
48 |
} |
} |
49 |
|
|
50 |
unsigned int Profiler::GetBogoVoices(unsigned int SamplingFreq) |
unsigned int Profiler::GetBogoVoices(unsigned int SamplingFreq) |
51 |
{ |
{ |
52 |
if (profilingSamples == 0) return 0; |
if (profilingSamples == 0) return 0; |
53 |
unsigned int avgTicks = profilingTime / profilingSamples; |
double avgTicks = ((double) profilingTime) / ((double) profilingSamples); |
54 |
unsigned int samplesPerSecond = ticksPerSecond / avgTicks; |
unsigned int samplesPerSecond = (unsigned int) (tsPerSecond / avgTicks); |
55 |
unsigned int bogoVoices = samplesPerSecond / SamplingFreq; |
unsigned int bogoVoices = samplesPerSecond / SamplingFreq; |
56 |
return bogoVoices; |
return bogoVoices; |
57 |
} |
} |