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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 328 - (hide annotations) (download)
Sat Dec 25 21:58:58 2004 UTC (19 years, 4 months ago) by schoenebeck
File size: 2692 byte(s)
* architecture independence fixes, should now compile again for non x86
  systems
* tiny fix of command line switch --version

1 senkov 326 /***************************************************************************
2     * *
3     * LinuxSampler - modular, streaming capable sampler *
4     * *
5     * Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck *
6     * *
7     * This program is free software; you can redistribute it and/or modify *
8     * it under the terms of the GNU General Public License as published by *
9     * the Free Software Foundation; either version 2 of the License, or *
10     * (at your option) any later version. *
11     * *
12     * This program is distributed in the hope that it will be useful, *
13     * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15     * GNU General Public License for more details. *
16     * *
17     * You should have received a copy of the GNU General Public License *
18     * along with this program; if not, write to the Free Software *
19     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
20     * MA 02111-1307 USA *
21     ***************************************************************************/
22    
23     #include "Profiler.h"
24     #include <time.h>
25    
26     namespace LinuxSampler { namespace gig {
27    
28     unsigned long long Profiler::profilingSamples = 0;
29     unsigned long long Profiler::profilingTime = 0;
30 schoenebeck 328 double Profiler::tsPerSecond = 0;
31 senkov 326
32     void Profiler::Calibrate( void )
33     {
34     clock_t start_time = clock();
35 schoenebeck 328 RTMath::time_stamp_t start_clocks = Stamp();
36 senkov 326 volatile int a = 1;
37     volatile int b = 1;
38     for (volatile int i = 0; i < 100000000; i++)
39     {
40     a += b;
41     }
42     clock_t stop_time = clock();
43 schoenebeck 328 RTMath::time_stamp_t stop_clocks = Stamp();
44     double diff_ticks = (stop_clocks - start_clocks);
45 senkov 326 double diff_time = ((stop_time - start_time) / (double(CLOCKS_PER_SEC)));
46 schoenebeck 328 tsPerSecond = diff_ticks / diff_time;
47 senkov 326 }
48    
49     unsigned int Profiler::GetBogoVoices(unsigned int SamplingFreq)
50     {
51     if (profilingSamples == 0) return 0;
52 schoenebeck 328 double avgTicks = ((double) profilingTime) / ((double) profilingSamples);
53     unsigned int samplesPerSecond = (unsigned int) (tsPerSecond / avgTicks);
54 senkov 326 unsigned int bogoVoices = samplesPerSecond / SamplingFreq;
55     return bogoVoices;
56     }
57    
58     }} // namespace LinuxSampler::gig

  ViewVC Help
Powered by ViewVC