Android Open Source - mazer Perf






From Project

Back to project page mazer.

License

The source code is released under:

GNU General Public License

If you think the Android project mazer listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package org.spatialia.santa.util;
/* w  w w.  ja  v a2  s  . c o m*/
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Class used to measure different aspects.
 */
public class Perf {

  private static Map<String, List<Long>> actionTimes = new HashMap<String, List<Long>>();
  private static Map<String, Long> startTimes = new HashMap<String, Long>();
  private static Map<String, Long> averageTimes = new HashMap<String, Long>();

  public static void start(String action) {
    startTimes.put(action, System.currentTimeMillis());
    if (!actionTimes.containsKey(action)) {
      actionTimes.put(action, new ArrayList<Long>());
    }
  }

  public static long end(String action) {
    long diff = System.currentTimeMillis() - startTimes.get(action);
    actionTimes.get(action).add(diff);
    return diff;
  }

  public static long average(String action, int count) {
    if (actionTimes.get(action).size() > count) {
      long sum = 0;
      for (Long l : actionTimes.get(action)) {
        sum += l;
      }
      long average = sum / actionTimes.get(action).size();
      averageTimes.put(action, average);
      actionTimes.get(action).clear();
      return average;
    } else {
      Long l = averageTimes.get(action);
      return l != null ? l : 0;
    }
  }
}




Java Source Code List

org.spatialia.santa.AlertDialog.java
org.spatialia.santa.GameEngine.java
org.spatialia.santa.GameInput.java
org.spatialia.santa.GameView.java
org.spatialia.santa.MainActivity.java
org.spatialia.santa.Sprite.java
org.spatialia.santa.Tile.java
org.spatialia.santa.logic.LevelManager.java
org.spatialia.santa.logic.Level.java
org.spatialia.santa.logic.Settings.java
org.spatialia.santa.util.JobRunner.java
org.spatialia.santa.util.Perf.java
org.spatialia.santa.util.Post.java