PerfTimer.java
1.66 KB
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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* org.slf4j.Logger
* org.slf4j.LoggerFactory
*/
package com.adobe.cq.mobile.dps.impl.ui;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class PerfTimer {
final Logger logger;
final String name;
long timer = 0;
String interimName = null;
long interimTimer = 0;
public static PerfTimer startTimer(Object object, String name) {
PerfTimer timer = new PerfTimer(object, name);
timer.start();
return timer;
}
private PerfTimer(Object object, String name) {
this.name = name;
this.logger = LoggerFactory.getLogger((String)("PERF." + object.getClass().getName()));
}
public void start() {
this.timer = System.currentTimeMillis();
this.logger.debug(this.name + " START ");
}
public void startInterim(String interimName) {
if (this.interimTimer > 0) {
this.logger.warn("Interim timer already started for " + interimName);
}
this.interimName = interimName;
this.interimTimer = System.currentTimeMillis();
this.logger.debug(this.name + ":" + this.interimName + " START ");
}
public void endInterim() {
if (this.interimTimer == 0) {
this.logger.warn("Interim timer not started");
} else {
this.logger.debug(this.name + ":" + this.interimName + " DONE " + (System.currentTimeMillis() - this.interimTimer) + "ms");
this.interimTimer = 0;
}
}
public void end() {
this.logger.debug(this.name + " DONE " + (System.currentTimeMillis() - this.timer) + "ms");
}
}