1 /*************************************************************************
2  *                                                                       *
3  * Tokamak Physics Engine, Copyright (C) 2002-2007 David Lam.            *
4  * All rights reserved.  Email: david@tokamakphysics.com                 *
5  *                       Web: www.tokamakphysics.com                     *
6  *                                                                       *
7  * This library is distributed in the hope that it will be useful,       *
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files    *
10  * LICENSE.TXT for more details.                                         *
11  *                                                                       *
12  *************************************************************************/
13 
14 #include "math/ne_type.h"
15 #include "math/ne_debug.h"
16 #include "tokamak.h"
17 #include "containers.h"
18 #include "scenery.h"
19 #include "collision.h"
20 #include "constraint.h"
21 #include "rigidbody.h"
22 #include "scenery.h"
23 
24 #include "stack.h"
25 #include "simulator.h"
26 #include "perflinux.h"
27 
28 #include <sys/time.h>
29 
Create()30 nePerformanceData * nePerformanceData::Create()
31 {
32 	return new nePerformanceData;
33 }
34 
35 s64 perfFreq;
36 
37 timeval counter;
38 
39 /****************************************************************************
40 *
41 *	nePerformanceData::Start
42 *
43 ****************************************************************************/
44 
DunselFunction()45 void DunselFunction() { return; }
46 
Init()47 void nePerformanceData::Init()
48 {
49 	Reset();
50 
51 	void (*pFunc)() = DunselFunction;
52 
53 	gettimeofday(&counter, NULL);
54 }
55 
Start()56 void nePerformanceData::Start()
57 {
58 	Reset();
59 
60 	gettimeofday(&counter, NULL);
61 }
62 
GetCount()63 f32 nePerformanceData::GetCount()
64 {
65 	timeval tStart, tStop;
66 	f32 start, end;
67 
68 	tStart = counter;
69 
70 	gettimeofday(&tStop, NULL);
71 
72 	start = (tStart.tv_sec * 1000000.0) + tStart.tv_usec;
73     end = (tStop.tv_sec * 1000000.0) + tStop.tv_usec;
74 
75 	return (end - start) * 0.000001;
76 }
77 
UpdateDynamic()78 void nePerformanceData::UpdateDynamic()
79 {
80 	dynamic += GetCount();
81 }
UpdatePosition()82 void nePerformanceData::UpdatePosition()
83 {
84 	position += GetCount();
85 }
UpdateConstrain1()86 void nePerformanceData::UpdateConstrain1()
87 {
88 	constrain_1 += GetCount();
89 }
UpdateConstrain2()90 void nePerformanceData::UpdateConstrain2()
91 {
92 	constrain_2 += GetCount();
93 }
UpdateCD()94 void nePerformanceData::UpdateCD()
95 {
96 	cd += GetCount();
97 }
UpdateCDCulling()98 void nePerformanceData::UpdateCDCulling()
99 {
100 	cdCulling += GetCount();
101 }
UpdateTerrain()102 void nePerformanceData::UpdateTerrain()
103 {
104 	terrain += GetCount();
105 }
UpdateControllerCallback()106 void nePerformanceData::UpdateControllerCallback()
107 {
108 	controllerCallback += GetCount();
109 }
UpdateTerrainCulling()110 void nePerformanceData::UpdateTerrainCulling()
111 {
112 	terrainCulling += GetCount();
113 }
114