Cleaning the examples' Makefiles and octaves scripts.
[Faustine.git] / interpretor / preprocessor / faust-0.9.47mr3 / compiler / errors / timing.cpp
1 #include <iostream>
2 #include <cassert>
3 #ifndef WIN32
4 #include <sys/time.h>
5 #endif
6 #include "timing.hh"
7
8 using namespace std;
9
10
11 #if 0
12 double mysecond()
13 {
14 struct timeval tp;
15 struct timezone tzp;
16 int i;
17
18 i = gettimeofday(&tp,&tzp);
19 return ( (double) tp.tv_sec + (double) tp.tv_usec * 1.e-6 );
20 }
21
22 int lIndex=0;
23 double lStartTime[1024];
24 double lEndTime[1024];
25
26 static void tab (int n, ostream& fout)
27 {
28 fout << '\n';
29 while (n--) fout << '\t';
30 }
31
32 void startTiming (const char* msg)
33 {
34 assert(lIndex < 1023);
35 tab(lIndex, cerr); cerr << "start " << msg << endl;
36 lStartTime[lIndex++] = mysecond();
37 }
38
39 void endTiming (const char* msg)
40 {
41 assert(lIndex>0);
42 lEndTime[--lIndex] = mysecond();
43 tab(lIndex, cerr); cerr << "end " << msg << " (duration : " << lEndTime[lIndex] - lStartTime[lIndex] << ")" << endl;
44 }
45
46 #else
47
48 void startTiming (const char* msg)
49 {}
50
51 void endTiming (const char* msg)
52 {}
53
54 #endif
55