From: adam Date: Sun, 9 Sep 2007 19:15:20 +0000 (-0400) Subject: added performance instrumentation (commented out) X-Git-Url: http://git.megacz.com/?p=sbp.git;a=commitdiff_plain;h=c805010980fc22bcd66c1684a772f66563cd6b72;ds=sidebyside added performance instrumentation (commented out) darcs-hash:20070909191520-5007d-1048c18cd8649d024b21bc46671083376c3a3c8c.gz --- diff --git a/src/edu/berkeley/sbp/GSS.java b/src/edu/berkeley/sbp/GSS.java index 3876d58..7626b4e 100644 --- a/src/edu/berkeley/sbp/GSS.java +++ b/src/edu/berkeley/sbp/GSS.java @@ -18,6 +18,9 @@ class GSS { public GSS(Input input, Parser parser) { this.input = input; this.parser = parser;} public Input getInput() { return input; } + /* + HashSet finishedReductions = new HashSet(); + */ int numNewNodes = 0; int numOldNodes = 0; int viewPos = 0; @@ -69,6 +72,9 @@ class GSS { this.pos = prev==null ? 0 : prev.pos+1; if (prev != null) prev.shift(this, forest); numReductions = 0; + /* + finishedReductions.clear(); + */ int minPhasePos = Integer.MAX_VALUE; Reduction best = null; @@ -94,6 +100,9 @@ class GSS { best = r; } } + /* + finishedReductions.add(r); + */ numReductions++; } if (token==null) shift(null, null); diff --git a/src/edu/berkeley/sbp/Parser.java b/src/edu/berkeley/sbp/Parser.java index 2fc0691..95e3ba5 100644 --- a/src/edu/berkeley/sbp/Parser.java +++ b/src/edu/berkeley/sbp/Parser.java @@ -24,22 +24,79 @@ public abstract class Parser implements Serializable { /** parse input, and return the shared packed parse forest (or throw an exception) */ public Forest parse(Input input) throws IOException, ParseFailed { + long start = System.currentTimeMillis(); verbose = System.getProperty("sbp.verbose", null) != null; spinpos = 0; GSS gss = new GSS(input, this); + int idmax = 0; + int[][] count = new int[1024*1024][]; + HashMap ids = new HashMap(); try { for(GSS.Phase current = gss.new Phase(pt.start); ;) { if (verbose) debug(current.token, gss, input); if (current.isDone()) return (Forest)current.finalResult; Input.Region region = current.getLocation().createRegion(current.getNextLocation()); Forest forest = shiftToken((Token)current.token, region); + /* + int maxid = 0; + for(Reduction r : gss.finishedReductions) + if (ids.get(r.reduction())==null) + ids.put(r.reduction(), idmax++); + count[current.pos] = new int[idmax]; + for(Reduction r : gss.finishedReductions) + count[current.pos][ids.get(r.reduction())]++; + */ current = gss.new Phase(current, forest); } } finally { if (verbose) { - System.err.print("\r"+ANSI.clreol()); + long time = System.currentTimeMillis() - start; + System.err.println("\r parse time: " + time +"ms "+ ANSI.clreol()); debug(null, gss, input); } + /* + PrintWriter pw = new PrintWriter(new OutputStreamWriter(new FileOutputStream("out.plot"))); + boolean[] use = new boolean[idmax]; + for(int i=0; i20) + use[j] = true; + for(int i=0; i=count[i].length ? 0 : count[i][j])); + } + pw.println(); + } + pw.close(); + pw = new PrintWriter(new OutputStreamWriter(new FileOutputStream("test.plot"))); + pw.println("set terminal postscript enhanced color"); + pw.println("set output \"out.ps\""); + pw.println("set pm3d map"); + pw.println("set autoscale"); + pw.println("set view 0,0"); + pw.println("set ytics (\\"); + int q = -1; + for(int j=0; j