mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-02 01:48:05 +00:00
Bug 741281 - Add Telemetry timers in Java. r=blassey
This commit is contained in:
parent
c81eabf714
commit
587c7e6213
@ -5,9 +5,9 @@
|
||||
|
||||
package org.mozilla.gecko;
|
||||
|
||||
import android.os.SystemClock;
|
||||
import android.util.Log;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
@ -33,4 +33,23 @@ public class Telemetry {
|
||||
Log.e(LOGTAG, "JSON exception: ", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Timer {
|
||||
private long mStartTime;
|
||||
private String mName;
|
||||
|
||||
public Timer(String name) {
|
||||
mName = name;
|
||||
mStartTime = SystemClock.uptimeMillis();
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
long elapsed = SystemClock.uptimeMillis() - mStartTime;
|
||||
if (elapsed < Integer.MAX_VALUE) {
|
||||
HistogramAdd(mName, (int)(elapsed));
|
||||
} else {
|
||||
Log.e(LOGTAG, "Duration of " + elapsed + " ms is too long.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user