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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 770 - (show annotations) (download)
Sun Sep 11 15:56:29 2005 UTC (18 years, 7 months ago) by schoenebeck
File size: 2726 byte(s)
* synthesis core optimizations

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

  ViewVC Help
Powered by ViewVC