forked from FionaWright/High5ive
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathZ_Debug.pde
60 lines (51 loc) · 1.44 KB
/
Z_Debug.pde
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
56
57
58
59
60
/**
* F. Wright
*
* Class for profiling code execution time.
*/
class DebugProfilerClass {
private Stack<Long> m_timerStack = new Stack<Long>();
/**
* F. Wright
*
* Starts a new profile timer.
*/
public void startProfileTimer() {
if (!DEBUG_MODE)
return;
m_timerStack.push(System.nanoTime());
}
/**
* F. Wright
*
* Prints the time taken in milliseconds since the last startProfileTimer() call.
*
* @param name The name of the profiled task.
*/
public void printTimeTakenMillis(String name) {
if (!DEBUG_MODE)
return;
for (int i = 1; i < m_timerStack.size(); i++)
print("-");
double millis = (System.nanoTime() - m_timerStack.pop()) / (double)MILLI_TO_NANO;
println("Milliseconds taken for [" + name + "] is " + millis + "ms");
}
/**
* F. Wright
*
* Prints the time taken in seconds since the last startProfileTimer() call.
*
* @param name The name of the profiled task.
*/
public void printTimeTakenSeconds(String name) {
if (!DEBUG_MODE)
return;
for (int i = 1; i < m_timerStack.size(); i++)
print("-");
double secs = (System.nanoTime() - m_timerStack.pop()) / (double)SECOND_TO_NANO;
println("Seconds taken for [" + name + "] is " + secs + "s");
}
}
// Descending code authorship changes:
// F. Wright, Created and implemented DebugProfilerClass using a stack, 2pm 06/03/24
// F. Wright, Deleted DebugFPSClass, 9am 19/03/24