1 package polyglot.frontend; 2 3 import java.util.*; 4 import java.io.PrintStream ; 5 6 import polyglot.util.*; 7 import polyglot.main.Report; 8 9 14 public class Stats 15 { 16 protected static class Times { 17 long inclusive; 18 long exclusive; 19 } 20 21 22 protected ExtensionInfo ext; 23 24 25 protected Map passTimes = new HashMap(); 26 27 31 protected List keys = new ArrayList(20); 32 33 public Stats(ExtensionInfo ext) { 34 this.ext = ext; 35 } 36 37 38 public void resetPassTimes(Object key) { 39 passTimes.remove(key); 40 } 41 42 43 public long passTime(Object key, boolean inclusive) { 44 Times t = (Times) passTimes.get(key); 45 if (t == null) { 46 return 0; 47 } 48 49 return inclusive ? t.inclusive : t.exclusive; 50 } 51 52 53 public void accumPassTimes(Object key, long in, long ex) { 54 Times t = (Times) passTimes.get(key); 55 if (t == null) { 56 keys.add(key); 57 t = new Times(); 58 passTimes.put(key, t); 59 } 60 t.inclusive += in; 61 t.exclusive += ex; 62 } 63 64 65 public void report() { 66 if (Report.should_report(Report.time, 1)) { 67 Report.report(1, "\nStatistics for " + ext.compilerName() + 68 " (" + ext.getClass().getName() + ")"); 69 Report.report(1, "Pass Inclusive Exclusive"); 70 Report.report(1, "---- --------- ---------"); 71 72 for (Iterator i = keys.iterator(); i.hasNext(); ) { 73 Object key = i.next(); 74 Times t = (Times) passTimes.get(key); 75 76 Report.report(1, key.toString() + " " + 77 t.inclusive + " " + t.exclusive); 78 } 79 } 80 } 81 } 82 | Popular Tags |