/[svn]/linuxsampler/trunk/src/engines/gig/Profiler.cpp
ViewVC logotype

Diff of /linuxsampler/trunk/src/engines/gig/Profiler.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 327 by senkov, Tue Dec 21 04:59:11 2004 UTC revision 328 by schoenebeck, Sat Dec 25 21:58:58 2004 UTC
# Line 27  namespace LinuxSampler { namespace gig { Line 27  namespace LinuxSampler { namespace gig {
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++)
# Line 40  namespace LinuxSampler { namespace gig { Line 40  namespace LinuxSampler { namespace gig {
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          }          }

Legend:
Removed from v.327  
changed lines
  Added in v.328

  ViewVC Help
Powered by ViewVC