Stopwatch.java
3.49 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
package com.google.common.base;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
import java.util.concurrent.TimeUnit;
@Beta
@GwtCompatible(emulated=true)
public final class Stopwatch
{
private final Ticker a;
private boolean b;
private long c;
private long d;
@Deprecated
Stopwatch()
{
this(Ticker.systemTicker());
}
@Deprecated
private Stopwatch(Ticker paramTicker)
{
this.a = ((Ticker)Preconditions.checkNotNull(paramTicker, "ticker"));
}
private long a()
{
if (this.b) {
return this.a.read() - this.d + this.c;
}
return this.c;
}
public static Stopwatch createStarted()
{
return new Stopwatch().start();
}
public static Stopwatch createStarted(Ticker paramTicker)
{
return new Stopwatch(paramTicker).start();
}
public static Stopwatch createUnstarted()
{
return new Stopwatch();
}
public static Stopwatch createUnstarted(Ticker paramTicker)
{
return new Stopwatch(paramTicker);
}
public final long elapsed(TimeUnit paramTimeUnit)
{
return paramTimeUnit.convert(a(), TimeUnit.NANOSECONDS);
}
public final boolean isRunning()
{
return this.b;
}
public final Stopwatch reset()
{
this.c = 0L;
this.b = false;
return this;
}
public final Stopwatch start()
{
if (!this.b) {}
for (boolean bool = true;; bool = false)
{
Preconditions.checkState(bool, "This stopwatch is already running.");
this.b = true;
this.d = this.a.read();
return this;
}
}
public final Stopwatch stop()
{
long l1 = this.a.read();
Preconditions.checkState(this.b, "This stopwatch is already stopped.");
this.b = false;
long l2 = this.c;
this.c = (l1 - this.d + l2);
return this;
}
@GwtIncompatible("String.format()")
public final String toString()
{
long l = a();
if (TimeUnit.DAYS.convert(l, TimeUnit.NANOSECONDS) > 0L) {
localObject = TimeUnit.DAYS;
}
double d1;
for (;;)
{
d1 = l / TimeUnit.NANOSECONDS.convert(1L, (TimeUnit)localObject);
switch (1.a[localObject.ordinal()])
{
default:
throw new AssertionError();
if (TimeUnit.HOURS.convert(l, TimeUnit.NANOSECONDS) > 0L) {
localObject = TimeUnit.HOURS;
} else if (TimeUnit.MINUTES.convert(l, TimeUnit.NANOSECONDS) > 0L) {
localObject = TimeUnit.MINUTES;
} else if (TimeUnit.SECONDS.convert(l, TimeUnit.NANOSECONDS) > 0L) {
localObject = TimeUnit.SECONDS;
} else if (TimeUnit.MILLISECONDS.convert(l, TimeUnit.NANOSECONDS) > 0L) {
localObject = TimeUnit.MILLISECONDS;
} else if (TimeUnit.MICROSECONDS.convert(l, TimeUnit.NANOSECONDS) > 0L) {
localObject = TimeUnit.MICROSECONDS;
} else {
localObject = TimeUnit.NANOSECONDS;
}
break;
}
}
Object localObject = "ns";
for (;;)
{
return String.format("%.4g %s", new Object[] { Double.valueOf(d1), localObject });
localObject = "μs";
continue;
localObject = "ms";
continue;
localObject = "s";
continue;
localObject = "min";
continue;
localObject = "h";
continue;
localObject = "d";
}
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/com/google/common/base/Stopwatch.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/