Java tutorial
//package com.java2s; //License from project: Apache License import android.util.Log; import java.text.NumberFormat; import java.util.HashMap; import java.util.Locale; public class Main { private static HashMap<String, Long> listTimes; public static void stopCounter(String tag) { long stopTime = System.currentTimeMillis(); if (listTimes.containsKey(tag)) { long startTime = listTimes.get(tag); long elapsedTime = stopTime - startTime; NumberFormat numberFormat = NumberFormat.getNumberInstance(Locale.US); System.out.println("#" + tag + "# {End counting :" + numberFormat.format(elapsedTime) + " ms }"); listTimes.remove(tag); } else Log.e(tag, "NO KEY IN HASHMAP To calculate Time"); } }