forked from subhamnaik15/Time-Stamp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Benchmarker.java
39 lines (33 loc) · 952 Bytes
/
Benchmarker.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
package com.takeoffandroid.multiselectrecyclergridview;
import android.util.Log;
import java.util.ArrayList;
/**
* Created by Bismita rath ,Subham Kumar Naik Satyam Kumar Naik
*/
public class Benchmarker {
private static ArrayList<Benchmark> mBenchmarks = new ArrayList<Benchmark>(5);
public static void start(String label) {
//Log.d("Benchmark", "Starting benchmark for: " + label);
Benchmark b = new Benchmark();
b.label = label;
b.startTime = System.currentTimeMillis();
mBenchmarks.add(b);
}
public static void stop(String label) {
long endTime = System.currentTimeMillis();
long startTime = -1;
for(Benchmark b : mBenchmarks) {
if(label.equals(b.label)) {
startTime = b.startTime;
mBenchmarks.remove(b);
break;
}
}
long elapsed = endTime - startTime;
Log.e("Benchmark", label + " finished in " + elapsed + " ms.");
}
private static class Benchmark {
long startTime;
String label;
}
}