@@ -41,15 +41,11 @@ public static void start() {
41
41
}
42
42
43
43
public static void start (String message ) {
44
- entryStack .set (new Profiler .Entry (message ,
45
- null ,
46
- null ));
44
+ entryStack .set (new Profiler .Entry (message , null , null ));
47
45
}
48
46
49
47
public static void start (Profiler .Message message ) {
50
- entryStack .set (new Profiler .Entry (message ,
51
- null ,
52
- null ));
48
+ entryStack .set (new Profiler .Entry (message , null , null ));
53
49
}
54
50
55
51
public static void reset () {
@@ -81,8 +77,7 @@ public static void release() {
81
77
}
82
78
83
79
public static long getDuration () {
84
- Profiler .Entry entry = (Profiler .Entry ) entryStack
85
- .get ();
80
+ Profiler .Entry entry = (Profiler .Entry ) entryStack .get ();
86
81
return entry != null ? entry .getDuration () : -1L ;
87
82
}
88
83
@@ -95,8 +90,7 @@ public static String dump(String prefix) {
95
90
}
96
91
97
92
public static String dump (String prefix1 , String prefix2 ) {
98
- Profiler .Entry entry = (Profiler .Entry ) entryStack
99
- .get ();
93
+ Profiler .Entry entry = (Profiler .Entry ) entryStack .get ();
100
94
return entry != null ? entry .toString (prefix1 , prefix2 ) : "" ;
101
95
}
102
96
@@ -105,8 +99,7 @@ public static Profiler.Entry getEntry() {
105
99
}
106
100
107
101
private static Profiler .Entry getCurrentEntry () {
108
- Profiler .Entry subEntry = (Profiler .Entry ) entryStack
109
- .get ();
102
+ Profiler .Entry subEntry = (Profiler .Entry ) entryStack .get ();
110
103
Profiler .Entry entry = null ;
111
104
if (subEntry != null ) {
112
105
do {
@@ -127,33 +120,30 @@ public interface Message {
127
120
}
128
121
129
122
public static final class MessageLevel extends IntegerEnum {
130
- private static final long serialVersionUID = 3257849896026388537L ;
131
- public static final Profiler .MessageLevel NO_MESSAGE = (Profiler .MessageLevel ) create ();
132
- public static final Profiler .MessageLevel BRIEF_MESSAGE = (Profiler .MessageLevel ) create ();
123
+ private static final long serialVersionUID = 3257849896026388537L ;
124
+ public static final Profiler .MessageLevel NO_MESSAGE = (Profiler .MessageLevel ) create ();
125
+ public static final Profiler .MessageLevel BRIEF_MESSAGE = (Profiler .MessageLevel ) create ();
133
126
public static final Profiler .MessageLevel DETAILED_MESSAGE = (Profiler .MessageLevel ) create ();
134
127
135
128
public MessageLevel () {
136
129
}
137
130
}
138
131
139
132
public static final class Entry {
140
- private final List subEntries ;
141
- private final Object message ;
133
+ private final List subEntries ;
134
+ private final Object message ;
142
135
private final Profiler .Entry parentEntry ;
143
136
private final Profiler .Entry firstEntry ;
144
- private final long baseTime ;
145
- private final long startTime ;
146
- private long endTime ;
137
+ private final long baseTime ;
138
+ private final long startTime ;
139
+ private long endTime ;
147
140
148
- private Entry (Object message ,
149
- Profiler .Entry parentEntry ,
150
- Profiler .Entry firstEntry ) {
141
+ private Entry (Object message , Profiler .Entry parentEntry , Profiler .Entry firstEntry ) {
151
142
this .subEntries = new ArrayList (4 );
152
143
this .message = message ;
153
144
this .startTime = System .currentTimeMillis ();
154
145
this .parentEntry = parentEntry ;
155
- this .firstEntry = (Profiler .Entry ) ObjectUtil
156
- .defaultIfNull (firstEntry , this );
146
+ this .firstEntry = (Profiler .Entry ) ObjectUtil .defaultIfNull (firstEntry , this );
157
147
this .baseTime = firstEntry == null ? 0L : firstEntry .startTime ;
158
148
}
159
149
@@ -198,8 +188,7 @@ public long getDurationOfSelf() {
198
188
return duration ;
199
189
} else {
200
190
for (int i = 0 ; i < this .subEntries .size (); ++i ) {
201
- Profiler .Entry subEntry = (Profiler .Entry ) this .subEntries
202
- .get (i );
191
+ Profiler .Entry subEntry = (Profiler .Entry ) this .subEntries .get (i );
203
192
duration -= subEntry .getDuration ();
204
193
}
205
194
@@ -240,16 +229,14 @@ private boolean isReleased() {
240
229
}
241
230
242
231
private void enterSubEntry (Object message ) {
243
- Profiler .Entry subEntry = new Profiler .Entry (
244
- message , this , this .firstEntry );
232
+ Profiler .Entry subEntry = new Profiler .Entry (message , this , this .firstEntry );
245
233
this .subEntries .add (subEntry );
246
234
}
247
235
248
236
private Profiler .Entry getUnreleasedEntry () {
249
237
Profiler .Entry subEntry = null ;
250
238
if (!this .subEntries .isEmpty ()) {
251
- subEntry = (Profiler .Entry ) this .subEntries
252
- .get (this .subEntries .size () - 1 );
239
+ subEntry = (Profiler .Entry ) this .subEntries .get (this .subEntries .size () - 1 );
253
240
if (subEntry .isReleased ()) {
254
241
subEntry = null ;
255
242
}
@@ -276,8 +263,8 @@ private void toString(StringBuffer buffer, String prefix1, String prefix2) {
276
263
long durationOfSelf = this .getDurationOfSelf ();
277
264
double percent = this .getPecentage ();
278
265
double percentOfAll = this .getPecentageOfAll ();
279
- Object [] params = new Object []{ message , new Long (startTime ), new Long (duration ),
280
- new Long (durationOfSelf ), new Double (percent ), new Double (percentOfAll )};
266
+ Object [] params = new Object [] { message , new Long (startTime ), new Long (duration ),
267
+ new Long (durationOfSelf ), new Double (percent ), new Double (percentOfAll ) };
281
268
StringBuffer pattern = new StringBuffer ("{1,number} " );
282
269
if (this .isReleased ()) {
283
270
pattern .append ("[{2,number}ms" );
@@ -305,8 +292,7 @@ private void toString(StringBuffer buffer, String prefix1, String prefix2) {
305
292
buffer .append (MessageFormat .format (pattern .toString (), params ));
306
293
307
294
for (int i = 0 ; i < this .subEntries .size (); ++i ) {
308
- Profiler .Entry subEntry = (Profiler .Entry ) this .subEntries
309
- .get (i );
295
+ Profiler .Entry subEntry = (Profiler .Entry ) this .subEntries .get (i );
310
296
buffer .append ('\n' );
311
297
if (i == this .subEntries .size () - 1 ) {
312
298
subEntry .toString (buffer , prefix2 + "`---" , prefix2 + " " );
0 commit comments