-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCompareTime.java
57 lines (48 loc) · 1.02 KB
/
CompareTime.java
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
public class CompareTime {
private int borneSup=10000;
private String string = "www.reflets.info";
private byte mode;
private BenchMark bench;
private String result;
StringBuilder build = new StringBuilder(string);
StringBuffer buff = new StringBuffer(string);
public CompareTime (byte mode) {
this.mode = mode;
exec();
}
public void doLoop() {
for (int i=0;i<borneSup;i++) {
if (mode == 0) {
result += string;
}else if (mode == 1){
build = build.append(string);
}else if (mode == 2) {
buff = buff.append(string);
}
}
//return result;
}
public void initBench() {
bench = new BenchMark();
}
public void exec() {
initBench();
bench.startMeUp();
doLoop();
bench.stopMe();
System.out.println(bench.showMe());
}
public void updateString(Object obj){
result = obj.toString();
}
public String getResult(){
if (mode == 0) {
return string;
}else if (mode == 1){
return build.toString();
}else if (mode == 2) {
return buff.toString();
}
return false+"";
}
}