| 1 package com.quadcap.jni; 2 3 40 41 import java.util.ArrayList ; 42 import java.util.Collections ; 43 import java.util.Comparator ; 44 import java.util.HashMap ; 45 import java.util.Iterator ; 46 47 52 public class Jni { 53 57 public static long getHiResFrequency() { 67 return 1000; 68 } 69 public static long getHiResTimer() { 70 return System.currentTimeMillis(); 71 } 72 static boolean silent = true; 73 75 long start = getHiResTimer(); 76 77 static int deferCount = 0; 78 79 static double F = (double)getHiResFrequency(); 80 public static Jni jni = new Jni(null); 81 static String lastStat; 82 83 public Jni() { 84 } 85 86 String name; 87 88 public Jni(String name) { 89 this.name = name; 90 } 91 92 public final double next() { 93 return 0; 101 } 103 104 public final static double D() { 105 return jni.next(); 106 } 107 108 public final void reset() { 109 } 113 114 public String toString() { 115 return name + ": " + next(); 116 } 117 118 int count = 0; 119 120 final public void dump(String s) { 121 } 132 133 static HashMap stats = new HashMap (); 134 135 final public void stat(String s) { 136 } 153 154 public static String formatInterval(double d, int pad) { 155 String unit = "ns"; 156 if (false) { 157 d = ((double)((long)d)) / 1000000.0; 158 unit = "ms"; 159 } else { 160 d = ((double)((long)d)) / 1000.0; 161 unit = "us"; 162 } 163 long dd = (long)d; 164 String ds = String.valueOf(dd); 165 long df = (long)((d - dd) * 100); 166 String fs = String.valueOf(df); 167 if (fs.length() < 2) fs = "0" + fs; 168 String s = ds + "." + fs + " " + unit; 169 if (pad > 0) { 170 while (s.length() < pad) s = " " + s; 171 } 172 return s; 173 } 174 175 String rpad(String s, int n) { 176 StringBuffer sb = new StringBuffer (s); 177 while (sb.length() < n) sb.append(' '); 178 return sb.toString(); 179 } 180 181 class StatCompare implements Comparator { 182 public int compare(Object a, Object b) { 183 double da = ((Stat)a).getTotal(); 184 double db = ((Stat)b).getTotal(); 185 if (da > db) return -1; 186 if (da < db) return 1; 187 return 0; 188 } 189 } 190 191 final public void clearStats(String x) { 192 if (x == null) { 193 stats = new HashMap (); 194 } else { 195 Iterator iter = stats.values().iterator(); 196 while (iter.hasNext()) { 197 Stat s = (Stat)iter.next(); 198 if (s.getName().startsWith(x)) { 199 iter.remove(); 200 } 201 } 202 } 203 jni.reset(); 204 } 205 206 final public void dumpStats(String x) { 207 } 231 232 public void finalize() throws Throwable { 233 dumpStats(null); 234 super.finalize(); 235 } 236 237 } 282 | Popular Tags |