Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. import android.util.Log;
  2.  
  3. import java.util.HashMap;
  4.  
  5. public class TimeMonitor {
  6. private final String TAG = "TimeMonitor";
  7. private int monitorId = -1;
  8. private HashMap<String,Long> mTimeTag = new HashMap<>();
  9. private long mStartTime = 0;
  10.  
  11. public TimeMonitor(int monitorId) {
  12. Log.d(TAG,"init TimeMonitor id "+monitorId);
  13. this.monitorId = monitorId;
  14. }
  15.  
  16. public int getMonitorId(){
  17. return monitorId;
  18. }
  19.  
  20. public void startMonitor(){
  21. if(mTimeTag.size()>0){
  22. mTimeTag.clear();
  23. }
  24. mStartTime = System.currentTimeMillis();
  25. }
  26.  
  27. /**
  28. * 打点统计时间 tag标记需要统计时间的模块或者方法
  29. * @param tag
  30. */
  31. public void recordingTimeTag(String tag){
  32. if(mTimeTag.get(tag)!=null){
  33. mTimeTag.remove(tag);
  34. }
  35.  
  36. long time = System.currentTimeMillis()-mStartTime;
  37. Log.e(TAG,tag+" : "+time);
  38. mTimeTag.put(tag,time);
  39. }
  40.  
  41.  
  42. public HashMap<String,Long> getmTimeTags(){
  43. return mTimeTag;
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement