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