Index: contrib/benchmark/src/test/org/apache/lucene/benchmark/byTask/TestPerfTasksLogic.java =================================================================== --- contrib/benchmark/src/test/org/apache/lucene/benchmark/byTask/TestPerfTasksLogic.java (revision 612564) +++ contrib/benchmark/src/test/org/apache/lucene/benchmark/byTask/TestPerfTasksLogic.java (working copy) @@ -296,7 +296,7 @@ "directory=RAMDirectory", "doc.stored=false", "doc.tokenized=false", - "debug.level=1", + "task.max.depth.log=1", "# ----- alg ", "CreateIndex", "{ [ AddDoc]: 4} : * ", @@ -374,7 +374,7 @@ "directory=RAMDirectory", "doc.stored=false", "doc.tokenized=false", - "debug.level=1", + "task.max.depth.log=1", "# ----- alg ", "{ \"Rounds\"", " ResetSystemErase", @@ -393,4 +393,63 @@ assertEquals("wrong number of docs in the index!", ndocsExpected, ir.numDocs()); ir.close(); } + + /** + * Test disabling task count (LUCENE-1136). + */ + public void testDisableCounting() throws Exception { + doTestDisableCounting(true); + doTestDisableCounting(false); + } + + private void doTestDisableCounting(boolean disable) throws Exception { + // 1. alg definition (required in every "logic" test) + String algLines[] = disableCountingLines(disable); + + // 2. execute the algorithm (required in every "logic" test) + Benchmark benchmark = execBenchmark(algLines); + + // 3. test counters + int n = disable ? 0 : 1; + int nChecked = 0; + for (Iterator ts = benchmark.getRunData().getPoints().taskStats().iterator(); ts.hasNext();) { + TaskStats stats = (TaskStats) ts.next(); + String taskName = stats.getTask().getName(); + if (taskName.equals("Rounds")) { + assertEquals("Wrong total count!",20+2*n,stats.getCount()); + nChecked++; + } else if (taskName.equals("CreateIndex")) { + assertEquals("Wrong count for CreateIndex!",n,stats.getCount()); + nChecked++; + } else if (taskName.equals("CloseIndex")) { + assertEquals("Wrong count for CloseIndex!",n,stats.getCount()); + nChecked++; + } + } + assertEquals("Missing some tasks to check!",3,nChecked); + } + + private static String[] disableCountingLines (boolean disable) { + String dis = disable ? "-" : ""; + return new String[] { + "# ----- properties ", + "doc.maker="+Reuters20DocMaker.class.getName(), + "doc.add.log.step=30", + "doc.term.vector=false", + "doc.maker.forever=false", + "directory=RAMDirectory", + "doc.stored=false", + "doc.tokenized=false", + "task.max.depth.log=1", + "# ----- alg ", + "{ \"Rounds\"", + " ResetSystemErase", + " "+dis+"CreateIndex", // optionally disable counting here + " { \"AddDocs\" AddDoc > : * ", + " "+dis+"CloseIndex", // optionally disable counting here + "}", + "RepSumByName", + }; + } + } Index: contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/utils/Algorithm.java =================================================================== --- contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/utils/Algorithm.java (revision 612564) +++ contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/utils/Algorithm.java (working copy) @@ -51,7 +51,9 @@ stok.ordinaryChar('/'); stok.ordinaryChar('('); stok.ordinaryChar(')'); + stok.ordinaryChar('-'); boolean colonOk = false; + boolean isDisableCountNextTask = false; // only for primitive tasks currSequence.setDepth(0); String taskPackage = PerfTask.class.getPackage().getName() + "."; @@ -65,6 +67,8 @@ String s = stok.sval; Constructor cnstr = Class.forName(taskPackage+s+"Task").getConstructor(paramClass); PerfTask task = (PerfTask) cnstr.newInstance(paramObj); + task.setDisableCounting(isDisableCountNextTask); + isDisableCountNextTask = false; currSequence.addTask(task); if (task instanceof RepSumByPrefTask) { stok.nextToken(); @@ -120,7 +124,8 @@ if ((char)stok.ttype == '*') { ((TaskSequence)prevTask).setRepetitions(TaskSequence.REPEAT_EXHAUST); } else { - if (stok.ttype!=StreamTokenizer.TT_NUMBER) throw new Exception("expexted repetitions number: - "+stok.toString()); + if (stok.ttype!=StreamTokenizer.TT_NUMBER) + throw new Exception("expexted repetitions number: - "+stok.toString()); ((TaskSequence)prevTask).setRepetitions((int)stok.nval); } // check for rate specification (ops/min) @@ -184,6 +189,10 @@ currSequence = currSequence.getParent(); break; + case '-' : + isDisableCountNextTask = true; + break; + } //switch(c) break; @@ -196,7 +205,7 @@ } // remove redundant top level enclosing sequences - while (sequence.getRepetitions()==1 && sequence.getRate()==0) { + while (sequence.isCollapsable() && sequence.getRepetitions()==1 && sequence.getRate()==0) { ArrayList t = sequence.getTasks(); if (t!=null && t.size()==1) { PerfTask p = (PerfTask) t.get(0); @@ -225,7 +234,7 @@ * @throws Exception */ public void execute() throws Exception { - sequence.doLogic(); + sequence.runAndMaybeStats(true); } /** Index: contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/PerfTask.java =================================================================== --- contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/PerfTask.java (revision 612564) +++ contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/PerfTask.java (working copy) @@ -41,6 +41,7 @@ private String name; private int depth = 0; private int maxDepthLogStart = 0; + private boolean disableCounting = false; protected String params = null; protected static final String NEW_LINE = System.getProperty("line.separator"); @@ -81,6 +82,7 @@ if (!reportStats || shouldNotRecordStats()) { setup(); int count = doLogic(); + count = disableCounting ? 0 : count; tearDown(); return count; } @@ -88,6 +90,7 @@ Points pnts = runData.getPoints(); TaskStats ts = pnts.markTaskStart(this,runData.getConfig().getRoundNumber()); int count = doLogic(); + count = disableCounting ? 0 : count; pnts.markTaskEnd(ts, count); tearDown(); return count; @@ -227,4 +230,18 @@ return params; } + /** + * Return true if counting is disabled for this task. + */ + public boolean isDisableCounting() { + return disableCounting; + } + + /** + * See {@link #isDisableCounting()} + */ + public void setDisableCounting(boolean disableCounting) { + this.disableCounting = disableCounting; + } + } Index: contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/TaskSequence.java =================================================================== --- contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/TaskSequence.java (revision 612564) +++ contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/TaskSequence.java (working copy) @@ -40,9 +40,11 @@ private boolean resetExhausted = false; private PerfTask[] tasksArray; private boolean anyExhaustibleTasks; + private boolean collapsable = false; // to not collapse external sequence named in alg. public TaskSequence (PerfRunData runData, String name, TaskSequence parent, boolean parallel) { super(runData); + collapsable = (name == null); name = (name!=null ? name : (parallel ? "Par" : "Seq")); setName(name); setSequenceName(); @@ -338,5 +340,12 @@ } return res; } + + /** + * Return true if can be collapsed in case it is outermost sequence + */ + public boolean isCollapsable() { + return collapsable; + } } Index: contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/package.html =================================================================== --- contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/package.html (revision 612564) +++ contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/package.html (working copy) @@ -286,6 +286,15 @@ waiting before starting next add, if otherwise rate would exceed 200 adds/min.