File: timing.cpp

package info (click to toggle)
faust 0.9.46-2
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 15,256 kB
  • ctags: 9,961
  • sloc: cpp: 47,746; sh: 2,254; ansic: 1,503; makefile: 1,211; ruby: 950; yacc: 468; objc: 459; lex: 200; xml: 177
file content (55 lines) | stat: -rw-r--r-- 957 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <iostream>
#include <cassert>
#ifndef WIN32
#include <sys/time.h>
#endif
#include "timing.hh"

using namespace std;


#if 0
double mysecond()
{
        struct timeval tp;
        struct timezone tzp;
        int i;

        i = gettimeofday(&tp,&tzp);
        return ( (double) tp.tv_sec + (double) tp.tv_usec * 1.e-6 );
}

int		lIndex=0;
double 	lStartTime[1024];
double 	lEndTime[1024];

static void tab (int n, ostream& fout)
{
        fout << '\n';
        while (n--)     fout << '\t'; 
}

void startTiming (const char* msg)
{
	assert(lIndex < 1023);
	tab(lIndex, cerr); cerr << "start " << msg << endl;
	lStartTime[lIndex++] = mysecond();
}

void endTiming (const char* msg)
{
	assert(lIndex>0);
	lEndTime[--lIndex] = mysecond();
	tab(lIndex, cerr); cerr << "end " << msg << " (duration : " << lEndTime[lIndex] - lStartTime[lIndex] << ")" << endl;
}

#else

void startTiming (const char* msg)
{}

void endTiming (const char* msg)
{}

#endif