lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gsing...@apache.org
Subject svn commit: r495834 [3/3] - in /lucene/java/trunk/contrib/benchmark: ./ conf/ src/java/org/apache/lucene/benchmark/byTask/ src/java/org/apache/lucene/benchmark/byTask/feeds/ src/java/org/apache/lucene/benchmark/byTask/programmatic/ src/java/org/apache/...
Date Sat, 13 Jan 2007 04:08:25 GMT
Added: lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/RepSumByNameRoundTask.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/RepSumByNameRoundTask.java?view=auto&rev=495834
==============================================================================
--- lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/RepSumByNameRoundTask.java (added)
+++ lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/RepSumByNameRoundTask.java Fri Jan 12 20:08:23 2007
@@ -0,0 +1,45 @@
+package org.apache.lucene.benchmark.byTask.tasks;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.lucene.benchmark.byTask.PerfRunData;
+import org.apache.lucene.benchmark.byTask.stats.Report;
+
+/**
+ * Report all statistics grouped/aggregated by name and round.
+ * Other side effects: None.
+ */
+public class RepSumByNameRoundTask extends ReportTask {
+
+  public RepSumByNameRoundTask(PerfRunData runData) {
+    super(runData);
+  }
+
+  public int doLogic() throws Exception {
+    Report rp = getRunData().getPoints().reportSumByNameRound();
+
+    System.out.println();
+    System.out.println("------------> Report Sum By (any) Name and Round ("+
+        rp.getSize()+" about "+rp.getReported()+" out of "+rp.getOutOf()+")");
+    System.out.println(rp.getText());
+    System.out.println();
+    
+    return 0;
+  }
+
+}

Added: lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/RepSumByNameTask.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/RepSumByNameTask.java?view=auto&rev=495834
==============================================================================
--- lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/RepSumByNameTask.java (added)
+++ lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/RepSumByNameTask.java Fri Jan 12 20:08:23 2007
@@ -0,0 +1,45 @@
+package org.apache.lucene.benchmark.byTask.tasks;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.lucene.benchmark.byTask.PerfRunData;
+import org.apache.lucene.benchmark.byTask.stats.Report;
+
+/**
+ * Report all statistics aggregated by name.
+ * Other side effects: None.
+ */
+public class RepSumByNameTask extends ReportTask {
+
+  public RepSumByNameTask(PerfRunData runData) {
+    super(runData);
+  }
+
+  public int doLogic() throws Exception {
+    Report rp = getRunData().getPoints().reportSumByName();
+
+    System.out.println();
+    System.out.println("------------> Report Sum By (any) Name ("+
+        rp.getSize()+" about "+rp.getReported()+" out of "+rp.getOutOf()+")");
+    System.out.println(rp.getText());
+    System.out.println();
+
+    return 0;
+  }
+
+}

Added: lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/RepSumByPrefRoundTask.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/RepSumByPrefRoundTask.java?view=auto&rev=495834
==============================================================================
--- lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/RepSumByPrefRoundTask.java (added)
+++ lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/RepSumByPrefRoundTask.java Fri Jan 12 20:08:23 2007
@@ -0,0 +1,45 @@
+package org.apache.lucene.benchmark.byTask.tasks;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.lucene.benchmark.byTask.PerfRunData;
+import org.apache.lucene.benchmark.byTask.stats.Report;
+
+/**
+ * Report all prefix matching statistics grouped/aggregated by name and round.
+ * Other side effects: None.
+ */
+public class RepSumByPrefRoundTask extends RepSumByPrefTask {
+
+  public RepSumByPrefRoundTask(PerfRunData runData) {
+    super(runData);
+  }
+
+  public int doLogic() throws Exception {
+    Report rp = getRunData().getPoints().reportSumByPrefixRound(prefix);
+    
+    System.out.println();
+    System.out.println("------------> Report sum by Prefix ("+prefix+") and Round ("+
+        rp.getSize()+" about "+rp.getReported()+" out of "+rp.getOutOf()+")");
+    System.out.println(rp.getText());
+    System.out.println();
+
+    return 0;
+  }
+
+}

Added: lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/RepSumByPrefTask.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/RepSumByPrefTask.java?view=auto&rev=495834
==============================================================================
--- lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/RepSumByPrefTask.java (added)
+++ lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/RepSumByPrefTask.java Fri Jan 12 20:08:23 2007
@@ -0,0 +1,58 @@
+package org.apache.lucene.benchmark.byTask.tasks;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.lucene.benchmark.byTask.PerfRunData;
+import org.apache.lucene.benchmark.byTask.stats.Report;
+
+/**
+ * Report by-name-prefix statistics aggregated by name.
+ * Other side effects: None.
+ */
+public class RepSumByPrefTask extends ReportTask {
+
+  public RepSumByPrefTask(PerfRunData runData) {
+    super(runData);
+  }
+
+  protected String prefix;
+
+  public int doLogic() throws Exception {
+    Report rp = getRunData().getPoints().reportSumByPrefix(prefix);
+    
+    System.out.println();
+    System.out.println("------------> Report Sum By Prefix ("+prefix+") ("+
+        rp.getSize()+" about "+rp.getReported()+" out of "+rp.getOutOf()+")");
+    System.out.println(rp.getText());
+    System.out.println();
+
+    return 0;
+  }
+
+  public void setPrefix(String prefix) {
+    this.prefix = prefix;
+  }
+
+  /* (non-Javadoc)
+   * @see PerfTask#toString()
+   */
+  public String toString() {
+    return super.toString()+" "+prefix;
+  }
+
+}

Added: lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ReportTask.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ReportTask.java?view=auto&rev=495834
==============================================================================
--- lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ReportTask.java (added)
+++ lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ReportTask.java Fri Jan 12 20:08:23 2007
@@ -0,0 +1,44 @@
+package org.apache.lucene.benchmark.byTask.tasks;
+
+import org.apache.lucene.benchmark.byTask.PerfRunData;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Report (abstract) task - all report tasks extend this task.
+ */
+public abstract class ReportTask extends PerfTask {
+
+  public ReportTask(PerfRunData runData) {
+    super(runData);
+  }
+
+  /* (non-Javadoc)
+   * @see PerfTask#shouldNeverLogAtStart()
+   */
+  protected boolean shouldNeverLogAtStart() {
+    return true;
+  }
+
+  /* (non-Javadoc)
+   * @see PerfTask#shouldNotRecordStats()
+   */
+  protected boolean shouldNotRecordStats() {
+    return true;
+  }
+}

Added: lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ResetInputsTask.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ResetInputsTask.java?view=auto&rev=495834
==============================================================================
--- lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ResetInputsTask.java (added)
+++ lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ResetInputsTask.java Fri Jan 12 20:08:23 2007
@@ -0,0 +1,48 @@
+package org.apache.lucene.benchmark.byTask.tasks;
+
+import org.apache.lucene.benchmark.byTask.PerfRunData;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+
+/**
+ * Reset inputs so that the test run would behave, input wise, 
+ * as if it just started. This affects e.g. the generation of docs and queries.
+ */
+public class ResetInputsTask extends PerfTask {
+
+  public ResetInputsTask(PerfRunData runData) {
+    super(runData);
+  }
+
+  public int doLogic() throws Exception {
+    getRunData().resetInputs();
+    return 0;
+  }
+  
+  /*
+   * (non-Javadoc)
+   * @see org.apache.lucene.benchmark.byTask.tasks.PerfTask#shouldNotRecordStats()
+   */
+  protected boolean shouldNotRecordStats() {
+    return true;
+  }
+
+
+}

Added: lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ResetSystemEraseTask.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ResetSystemEraseTask.java?view=auto&rev=495834
==============================================================================
--- lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ResetSystemEraseTask.java (added)
+++ lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ResetSystemEraseTask.java Fri Jan 12 20:08:23 2007
@@ -0,0 +1,50 @@
+package org.apache.lucene.benchmark.byTask.tasks;
+
+import org.apache.lucene.benchmark.byTask.PerfRunData;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+
+/**
+ * Reset all index and input data and call gc, erase index and dir, does NOT clear statistics.
+ * This contains ResetInputs.
+ * Other side effects: writers/readers nulified, deleted, closed.
+ * Index is erased.
+ * Directory is erased.
+ */
+public class ResetSystemEraseTask extends PerfTask {
+
+  public ResetSystemEraseTask(PerfRunData runData) {
+    super(runData);
+  }
+
+  public int doLogic() throws Exception {
+    getRunData().reinit(true);
+    return 0;
+  }
+  
+  /*
+   * (non-Javadoc)
+   * @see org.apache.lucene.benchmark.byTask.tasks.PerfTask#shouldNotRecordStats()
+   */
+  protected boolean shouldNotRecordStats() {
+    return true;
+  }
+
+}

Added: lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ResetSystemSoftTask.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ResetSystemSoftTask.java?view=auto&rev=495834
==============================================================================
--- lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ResetSystemSoftTask.java (added)
+++ lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ResetSystemSoftTask.java Fri Jan 12 20:08:23 2007
@@ -0,0 +1,50 @@
+package org.apache.lucene.benchmark.byTask.tasks;
+
+import org.apache.lucene.benchmark.byTask.PerfRunData;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+
+/**
+ * Reset all index and input data and call gc, does NOT erase index/dir, does NOT clear statistics.
+ * This contains ResetInputs.
+ * Other side effects: writers/readers nulified, closed.
+ * Index is NOT erased.
+ * Directory is NOT erased.
+ */
+public class ResetSystemSoftTask extends PerfTask {
+
+  public ResetSystemSoftTask(PerfRunData runData) {
+    super(runData);
+  }
+
+  public int doLogic() throws Exception {
+    getRunData().reinit(false);
+    return 0;
+  }
+
+  /*
+   * (non-Javadoc)
+   * @see org.apache.lucene.benchmark.byTask.tasks.PerfTask#shouldNotRecordStats()
+   */
+  protected boolean shouldNotRecordStats() {
+    return true;
+  }
+
+}

Added: lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchTask.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchTask.java?view=auto&rev=495834
==============================================================================
--- lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchTask.java (added)
+++ lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchTask.java Fri Jan 12 20:08:23 2007
@@ -0,0 +1,53 @@
+package org.apache.lucene.benchmark.byTask.tasks;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.lucene.benchmark.byTask.PerfRunData;
+import org.apache.lucene.benchmark.byTask.feeds.QueryMaker;
+
+/**
+ * Search task.
+ */
+public class SearchTask extends ReadTask {
+
+  public SearchTask(PerfRunData runData) {
+    super(runData);
+  }
+
+  public boolean withRetrieve() {
+    return false;
+  }
+
+  public boolean withSearch() {
+    return true;
+  }
+
+  public boolean withTraverse() {
+    return false;
+  }
+
+  public boolean withWarm() {
+    return false;
+  }
+
+  public QueryMaker getQueryMaker() {
+    return getRunData().getSearchQueryMaker();
+  }
+
+
+}

Added: lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchTravRetTask.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchTravRetTask.java?view=auto&rev=495834
==============================================================================
--- lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchTravRetTask.java (added)
+++ lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchTravRetTask.java Fri Jan 12 20:08:23 2007
@@ -0,0 +1,53 @@
+package org.apache.lucene.benchmark.byTask.tasks;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.lucene.benchmark.byTask.PerfRunData;
+import org.apache.lucene.benchmark.byTask.feeds.QueryMaker;
+
+/**
+ * Search and Travrese and Retrieve docs task.
+ */
+public class SearchTravRetTask extends ReadTask {
+
+  public SearchTravRetTask(PerfRunData runData) {
+    super(runData);
+  }
+
+  public boolean withRetrieve() {
+    return true;
+  }
+
+  public boolean withSearch() {
+    return true;
+  }
+
+  public boolean withTraverse() {
+    return true;
+  }
+
+  public boolean withWarm() {
+    return false;
+  }
+
+  public QueryMaker getQueryMaker() {
+    return getRunData().getSearchTravQueryMaker();
+  }
+
+
+}

Added: lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchTravTask.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchTravTask.java?view=auto&rev=495834
==============================================================================
--- lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchTravTask.java (added)
+++ lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchTravTask.java Fri Jan 12 20:08:23 2007
@@ -0,0 +1,52 @@
+package org.apache.lucene.benchmark.byTask.tasks;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.lucene.benchmark.byTask.PerfRunData;
+import org.apache.lucene.benchmark.byTask.feeds.QueryMaker;
+
+/**
+ * Search and Travrese task.
+ */
+public class SearchTravTask extends ReadTask {
+
+  public SearchTravTask(PerfRunData runData) {
+    super(runData);
+  }
+
+  public boolean withRetrieve() {
+    return false;
+  }
+
+  public boolean withSearch() {
+    return true;
+  }
+
+  public boolean withTraverse() {
+    return true;
+  }
+
+  public boolean withWarm() {
+    return false;
+  }
+
+  public QueryMaker getQueryMaker() {
+    return getRunData().getSearchTravRetQueryMaker();
+  }
+
+}

Added: lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SetPropTask.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SetPropTask.java?view=auto&rev=495834
==============================================================================
--- lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SetPropTask.java (added)
+++ lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SetPropTask.java Fri Jan 12 20:08:23 2007
@@ -0,0 +1,58 @@
+package org.apache.lucene.benchmark.byTask.tasks;
+
+import org.apache.lucene.benchmark.byTask.PerfRunData;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Set a performance test configuration property.
+ * A property may have a single value, or a sequence of values, seprated by ":". 
+ * If a sequence of values is specified, each time a new round starts, 
+ * the next (cyclic) value is taken.  
+ * Other side effects: none.
+ * @see org.apache.lucene.benchmark.byTask.tasks.NewRoundTask
+ */
+public class SetPropTask extends PerfTask {
+
+  public SetPropTask(PerfRunData runData) {
+    super(runData);
+  }
+
+  private String name;
+  private String value;
+  
+  public int doLogic() throws Exception {
+    if (name==null || value==null) {
+      throw new Exception(getName()+" - undefined name or value: name="+name+" value="+value);
+    }
+    getRunData().getConfig().set(name,value);
+    return 0;
+  }
+
+  /**
+   * Set the params (property name and value).
+   * @param params property name and value separated by ','.
+   */
+  public void setParams(String params) {
+    super.setParams(params);
+    int k = params.indexOf(",");
+    name = params.substring(0,k).trim();
+    value = params.substring(k+1).trim();
+  }
+
+}

Added: lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/TaskSequence.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/TaskSequence.java?view=auto&rev=495834
==============================================================================
--- lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/TaskSequence.java (added)
+++ lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/TaskSequence.java Fri Jan 12 20:08:23 2007
@@ -0,0 +1,269 @@
+package org.apache.lucene.benchmark.byTask.tasks;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.apache.lucene.benchmark.byTask.PerfRunData;
+
+/**
+ * Sequence of parallel or sequential tasks.
+ */
+public class TaskSequence extends PerfTask {
+  private ArrayList tasks;
+  private int repetitions = 1;
+  private boolean parallel;
+  private TaskSequence parent;
+  private boolean letChildReport = true;
+  private int rate = 0;
+  private boolean perMin = false; // rate, if set, is, by default, be sec.
+  private String seqName; 
+  
+  public TaskSequence (PerfRunData runData, String name, TaskSequence parent, boolean parallel) {
+    super(runData);
+    name = (name!=null ? name : (parallel ? "Par" : "Seq"));
+    setName(name);
+    setSequenceName();
+    this.parent = parent;
+    this.parallel = parallel;
+    tasks = new ArrayList();
+  }
+
+  /**
+   * @return Returns the parallel.
+   */
+  public boolean isParallel() {
+    return parallel;
+  }
+
+  /**
+   * @return Returns the repetitions.
+   */
+  public int getRepetitions() {
+    return repetitions;
+  }
+
+  /**
+   * @param repetitions The repetitions to set.
+   */
+  public void setRepetitions(int repetitions) {
+    this.repetitions = repetitions;
+    setSequenceName();
+  }
+
+  /**
+   * @return Returns the parent.
+   */
+  public TaskSequence getParent() {
+    return parent;
+  }
+
+  /*
+   * (non-Javadoc)
+   * @see org.apache.lucene.benchmark.byTask.tasks.PerfTask#doLogic()
+   */
+  public int doLogic() throws Exception {
+    return ( parallel ? doParallelTasks() : doSerialTasks());
+  }
+
+  private int doSerialTasks() throws Exception {
+    if (rate > 0) {
+      return doSerialTasksWithRate();
+    }
+    
+    int count = 0;
+    for (int k=0; k<repetitions; k++) {
+      for (Iterator it = tasks.iterator(); it.hasNext();) {
+        PerfTask task = (PerfTask) it.next();
+        count += task.runAndMaybeStats(letChildReport);
+      }
+    }
+    return count;
+  }
+
+  private int doSerialTasksWithRate() throws Exception {
+    long delayStep = (perMin ? 60000 : 1000) /rate;
+    long nextStartTime = System.currentTimeMillis();
+    int count = 0;
+    for (int k=0; k<repetitions; k++) {
+      for (Iterator it = tasks.iterator(); it.hasNext();) {
+        PerfTask task = (PerfTask) it.next();
+        long waitMore = nextStartTime - System.currentTimeMillis();
+        if (waitMore > 0) {
+          //System.out.println("wait: "+waitMore+" for rate: "+ratePerMin+" (delayStep="+delayStep+")");
+          Thread.sleep(waitMore);
+        }
+        nextStartTime += delayStep; // this aims at avarage rate. 
+        count += task.runAndMaybeStats(letChildReport);
+      }
+    }
+    return count;
+  }
+
+  private int doParallelTasks() throws Exception {
+    final int count [] = {0};
+    Thread t[] = new Thread [repetitions * tasks.size()];
+    // prepare threads
+    int indx = 0;
+    for (int k=0; k<repetitions; k++) {
+      for (int i = 0; i < tasks.size(); i++) {
+        final PerfTask task = (PerfTask) ((PerfTask) tasks.get(i)).clone();
+        t[indx++] = new Thread() {
+          public void run() {
+            int n;
+            try {
+              n = task.runAndMaybeStats(letChildReport);
+            } catch (Exception e) {
+              throw new RuntimeException(e);
+            }
+            synchronized (count) {
+              count[0] += n;
+            }
+          }
+        };
+      }
+    }
+    // run threads
+    startThreads(t);
+    // wait for all threads to complete
+    for (int i = 0; i < t.length; i++) {
+      t[i].join();
+    }
+    // return total count
+    return count[0];
+  }
+
+  // run threads
+  private void startThreads(Thread[] t) throws InterruptedException {
+    if (rate > 0) {
+      startlThreadsWithRate(t);
+      return;
+    }
+    for (int i = 0; i < t.length; i++) {
+      t[i].start();
+    }
+  }
+
+  // run threadsm with rate
+  private void startlThreadsWithRate(Thread[] t) throws InterruptedException {
+    long delayStep = (perMin ? 60000 : 1000) /rate;
+    long nextStartTime = System.currentTimeMillis();
+    for (int i = 0; i < t.length; i++) {
+      long waitMore = nextStartTime - System.currentTimeMillis();
+      if (waitMore > 0) {
+        //System.out.println("thread wait: "+waitMore+" for rate: "+ratePerMin+" (delayStep="+delayStep+")");
+        Thread.sleep(waitMore);
+      }
+      nextStartTime += delayStep; // this aims at avarage rate of starting threads. 
+      t[i].start();
+    }
+  }
+
+  public void addTask(PerfTask task) {
+    tasks.add(task);
+    task.setDepth(getDepth()+1);
+  }
+  
+  /* (non-Javadoc)
+   * @see java.lang.Object#toString()
+   */
+  public String toString() {
+    String padd = getPadding();
+    StringBuffer sb = new StringBuffer(super.toString());
+    sb.append(parallel ? " [" : " {");
+    sb.append(NEW_LINE);
+    for (Iterator it = tasks.iterator(); it.hasNext();) {
+      PerfTask task = (PerfTask) it.next();
+      sb.append(task.toString());
+      sb.append(NEW_LINE);
+    }
+    sb.append(padd);
+    sb.append(!letChildReport ? ">" : (parallel ? "]" : "}"));
+    if (repetitions>1) {
+      sb.append(" * " + repetitions);
+    }
+    if (rate>0) {
+      sb.append(",  rate: " + rate+"/"+(perMin?"min":"sec"));
+    }
+    return sb.toString();
+  }
+
+  /**
+   * Execute child tasks in a way that they do not reprt their time separately.
+   * Current implementation if child tasks has child tasks of their own, those are not affected by this call. 
+   */
+  public void setNoChildReport() {
+    letChildReport  = false;
+  }
+
+  /**
+   * Returns the rate per minute: how many operations should be performed in a minute.
+   * If 0 this has no effect.
+   * @return the rate per min: how many operations should be performed in a minute.
+   */
+  public int getRate() {
+    return (perMin ? rate : 60*rate);
+  }
+
+  /**
+   * @param rate The rate to set.
+   */
+  public void setRate(int rate, boolean perMin) {
+    this.rate = rate;
+    this.perMin = perMin;
+    setSequenceName();
+  }
+
+  private void setSequenceName() {
+    seqName = super.getName();
+    if (repetitions>1) {
+      seqName += "_"+repetitions;
+    }
+    if (rate>0) {
+      seqName += "_" + rate + (perMin?"/min":"/sec"); 
+    }
+    if (parallel && seqName.toLowerCase().indexOf("par")<0) {
+      seqName += "_Par";
+    }
+  }
+
+  public String getName() {
+    return seqName; // overide to include more info 
+  }
+
+  /**
+   * @return Returns the tasks.
+   */
+  public ArrayList getTasks() {
+    return tasks;
+  }
+
+  /* (non-Javadoc)
+   * @see java.lang.Object#clone()
+   */
+  protected Object clone() throws CloneNotSupportedException {
+    TaskSequence res = (TaskSequence) super.clone();
+    res.tasks = new ArrayList();
+    for (int i = 0; i < tasks.size(); i++) {
+      res.tasks.add(((PerfTask)tasks.get(i)).clone());
+    }
+    return res;
+  }
+  
+}

Added: lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/WarmTask.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/WarmTask.java?view=auto&rev=495834
==============================================================================
--- lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/WarmTask.java (added)
+++ lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/WarmTask.java Fri Jan 12 20:08:23 2007
@@ -0,0 +1,53 @@
+package org.apache.lucene.benchmark.byTask.tasks;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.lucene.benchmark.byTask.PerfRunData;
+import org.apache.lucene.benchmark.byTask.feeds.QueryMaker;
+
+/**
+ * Warm reader task.
+ */
+public class WarmTask extends ReadTask {
+
+  public WarmTask(PerfRunData runData) {
+    super(runData);
+  }
+
+  public boolean withRetrieve() {
+    return false;
+  }
+
+  public boolean withSearch() {
+    return false;
+  }
+
+  public boolean withTraverse() {
+    return false;
+  }
+
+  public boolean withWarm() {
+    return true;
+  }
+
+  public QueryMaker getQueryMaker() {
+    return null; // not required for this task.
+  }
+
+
+}

Added: lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/package.html
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/package.html?view=auto&rev=495834
==============================================================================
--- lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/package.html (added)
+++ lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/package.html Fri Jan 12 20:08:23 2007
@@ -0,0 +1,9 @@
+<html>
+<head>
+   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+   <meta name="Author" content="Doron Cohen">
+</head>
+<body>
+Extendable benchmark tasks.
+</body>
+</html>

Added: lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/utils/Algorithm.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/utils/Algorithm.java?view=auto&rev=495834
==============================================================================
--- lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/utils/Algorithm.java (added)
+++ lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/utils/Algorithm.java Fri Jan 12 20:08:23 2007
@@ -0,0 +1,229 @@
+package org.apache.lucene.benchmark.byTask.utils;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.StreamTokenizer;
+import java.io.StringReader;
+import java.lang.reflect.Constructor;
+import java.util.ArrayList;
+
+import org.apache.lucene.benchmark.byTask.PerfRunData;
+import org.apache.lucene.benchmark.byTask.tasks.PerfTask;
+import org.apache.lucene.benchmark.byTask.tasks.RepSumByPrefTask;
+import org.apache.lucene.benchmark.byTask.tasks.TaskSequence;
+
+/**
+ * Test algorithm, as read from file
+ */
+public class Algorithm {
+  
+  private TaskSequence sequence;
+  
+  /**
+   * Read algorithm from file
+   * @param runData perf-run-data used at running the tasks.
+   * @throws Exception if errors while parsing the algorithm 
+   */
+  public Algorithm (PerfRunData runData) throws Exception {
+    String algTxt = runData.getConfig().getAlgorithmText();
+    sequence = new TaskSequence(runData,null,null,false);
+    TaskSequence currSequence = sequence;
+    PerfTask prevTask = null;
+    StreamTokenizer stok = new StreamTokenizer(new StringReader(algTxt));
+    stok.commentChar('#');
+    stok.eolIsSignificant(false);
+    stok.ordinaryChar('"');
+    stok.ordinaryChar('/');
+    stok.ordinaryChar('(');
+    stok.ordinaryChar(')');
+    boolean colonOk = false; 
+    currSequence.setDepth(0);
+    String taskPackage = PerfTask.class.getPackage().getName() + ".";
+    
+    Class paramClass[] = {PerfRunData.class};
+    PerfRunData paramObj[] = {runData};
+    
+    while (stok.nextToken() != StreamTokenizer.TT_EOF) { 
+      switch(stok.ttype) {
+  
+        case StreamTokenizer.TT_WORD:
+          String s = stok.sval;
+          Constructor cnstr = Class.forName(taskPackage+s+"Task").getConstructor(paramClass);
+          PerfTask task = (PerfTask) cnstr.newInstance(paramObj);
+          currSequence.addTask(task);
+          if (task instanceof RepSumByPrefTask) {
+            stok.nextToken();
+            String prefix = stok.sval;
+            if (prefix==null || prefix.length()==0) { 
+              throw new Exception("named report prefix problem - "+stok.toString()); 
+            }
+            ((RepSumByPrefTask) task).setPrefix(prefix);
+          }
+          // check for task param: '(' someParam ')'
+          stok.nextToken();
+          if (stok.ttype!='(') {
+            stok.pushBack();
+          } else {
+            // get params, for tasks that supports them, - anything until next ')'
+            StringBuffer params = new StringBuffer();
+            stok.nextToken();
+            while (stok.ttype!=')') { 
+              switch (stok.ttype) {
+                case StreamTokenizer.TT_NUMBER:  
+                  params.append(stok.nval);
+                  break;
+                case StreamTokenizer.TT_WORD:    
+                  params.append(stok.sval);             
+                  break;
+                case StreamTokenizer.TT_EOF:     
+                  throw new Exception("unexpexted EOF: - "+stok.toString());
+                default:
+                  params.append((char)stok.ttype);
+              }
+              stok.nextToken();
+            }
+            String prm = params.toString().trim();
+            if (prm.length()>0) {
+              task.setParams(prm);
+            }
+          }
+
+          // ---------------------------------------
+          colonOk = false; prevTask = task;
+          break;
+  
+        default:
+          char c = (char)stok.ttype;
+          
+          switch(c) {
+          
+            case ':' :
+              if (!colonOk) throw new Exception("colon unexpexted: - "+stok.toString());
+              colonOk = false;
+              // get repetitions number
+              stok.nextToken();
+              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)
+              stok.nextToken();
+              if (stok.ttype!=':') {
+                stok.pushBack();
+              } else {
+                // get rate number
+                stok.nextToken();
+                if (stok.ttype!=StreamTokenizer.TT_NUMBER) throw new Exception("expexted rate number: - "+stok.toString());
+                // check for unit - min or sec, sec is default
+                stok.nextToken();
+                if (stok.ttype!='/') {
+                  stok.pushBack();
+                  ((TaskSequence)prevTask).setRate((int)stok.nval,false); // set rate per sec
+                } else {
+                  stok.nextToken();
+                  if (stok.ttype!=StreamTokenizer.TT_WORD) throw new Exception("expexted rate unit: 'min' or 'sec' - "+stok.toString());
+                  String unit = stok.sval.toLowerCase();
+                  if ("min".equals(unit)) {
+                    ((TaskSequence)prevTask).setRate((int)stok.nval,true); // set rate per min
+                  } else if ("sec".equals(unit)) {
+                    ((TaskSequence)prevTask).setRate((int)stok.nval,false); // set rate per sec
+                  } else {
+                    throw new Exception("expexted rate unit: 'min' or 'sec' - "+stok.toString());
+                  }
+                }
+              }
+              colonOk = false;
+              break;
+    
+            case '{' : 
+            case '[' :  
+              // a sequence
+              // check for sequence name
+              String name = null;
+              stok.nextToken();
+              if (stok.ttype!='"') {
+                stok.pushBack();
+              } else {
+                stok.nextToken();
+                name = stok.sval;
+                stok.nextToken();
+                if (stok.ttype!='"' || name==null || name.length()==0) { 
+                  throw new Exception("sequence name problem - "+stok.toString()); 
+                }
+              }
+              // start the sequence
+              TaskSequence seq2 = new TaskSequence(runData, name, currSequence, c=='[');
+              currSequence.addTask(seq2);
+              currSequence = seq2;
+              colonOk = false;
+              break;
+    
+            case '>' :
+              currSequence.setNoChildReport();
+            case '}' : 
+            case ']' : 
+              // end sequence
+              colonOk = true; prevTask = currSequence;
+              currSequence = currSequence.getParent();
+              break;
+          
+          } //switch(c)
+          break;
+          
+      } //switch(stok.ttype)
+      
+    }
+    
+    if (sequence != currSequence) {
+      throw new Exception("Unmatched sequences");
+    }
+    
+    // remove redundant top level enclosing sequences
+    while (sequence.getRepetitions()==1 && sequence.getRate()==0) {
+      ArrayList t = sequence.getTasks();
+      if (t!=null && t.size()==1) {
+        PerfTask p = (PerfTask) t.get(0);
+        if (p instanceof TaskSequence) {
+          sequence = (TaskSequence) p;
+          continue;
+        }
+      }
+      break;
+    }
+  }
+
+  /* (non-Javadoc)
+   * @see java.lang.Object#toString()
+   */
+  public String toString() {
+    String newline = System.getProperty("line.separator");
+    StringBuffer sb = new StringBuffer();
+    sb.append(sequence.toString());
+    sb.append(newline);
+    return sb.toString();
+  }
+
+  /**
+   * Execute this algorithm
+   * @throws Exception 
+   */
+  public void execute() throws Exception {
+    sequence.doLogic();
+  }
+  
+  
+}
+

Added: lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/utils/Config.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/utils/Config.java?view=auto&rev=495834
==============================================================================
--- lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/utils/Config.java (added)
+++ lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/utils/Config.java Fri Jan 12 20:08:23 2007
@@ -0,0 +1,325 @@
+package org.apache.lucene.benchmark.byTask.utils;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.StringTokenizer;
+
+/**
+ * Perf run configuration properties.
+ * Numeric peroperty containing ":", e.g. "10:100:5" is interpreted 
+ * as array of numeric values. It is extracted once, on first use, and 
+ * maintain an round number to return the appropriate value.   
+ */
+public class Config {
+
+  private static final String NEW_LINE = System.getProperty("line.separator");
+
+  private int roundNumber = 0;
+  private Properties props;
+  private HashMap valByRound = new HashMap();
+  private HashMap colForValByRound = new HashMap();
+  private String algorithmText;
+
+  /**
+   * Read config from file containing both algorithm and config properties.
+   * @param algFile file containing both algorithm and config properties.
+   * @throws IOException
+   */
+  public Config (File algFile) throws IOException {
+    // read alg file to array of lines
+    ArrayList lines = new ArrayList();
+    BufferedReader r = new BufferedReader(new FileReader(algFile));
+    int lastConfigLine=0;
+    for (String line = r.readLine(); line!=null; line=r.readLine()) {
+      lines.add(line);
+      if (line.indexOf('=')>0) {
+        lastConfigLine = lines.size();
+      }
+    }
+    r.close();
+    // copy props lines to string
+    StringBuffer sb = new StringBuffer();
+    for (int i=0; i<lastConfigLine; i++) {
+      sb.append(lines.get(i));
+      sb.append(NEW_LINE);
+    }
+    // read props from string
+    this.props = new Properties();
+    props.load(new ByteArrayInputStream(sb.toString().getBytes()));
+
+    if (Boolean.valueOf(props.getProperty("print.props","true")).booleanValue()) {
+      printProps();
+    }
+    
+    // copy algorithm lines
+    sb = new StringBuffer();
+    for (int i=lastConfigLine; i<lines.size(); i++) {
+      sb.append(lines.get(i));
+      sb.append(NEW_LINE);
+    }
+    algorithmText = sb.toString();
+  }
+
+  /**
+   * Create config without algorithm - usefull for a programmatic perf test.
+   * @param props - configuration properties.
+   * @throws IOException
+   */
+  public Config (Properties props) {
+    this.props = props;
+    if (Boolean.valueOf(props.getProperty("print.props","true")).booleanValue()) {
+      printProps();
+    }
+  }
+
+  private void printProps() {
+    System.out.println("------------> config properties:");
+    for (Iterator it = props.keySet().iterator(); it.hasNext();) {
+      String propName = (String) it.next();
+      System.out.println(propName + " = " + props.getProperty(propName));
+    }
+    System.out.println("-------------------------------");
+  }
+
+  /**
+   * Return a string property.
+   * @param name name of property.
+   * @param dflt default value.
+   * @return a string property.
+   */
+  public String get (String name, String dflt) {
+    return props.getProperty(name,dflt);
+  }
+
+  /**
+   * Set a property.
+   * Note: once a multiple values property is set, it can no longer be modified.
+   * @param name name of property.
+   * @param value either single or multiple propery value (multple values are separated by ":")
+   * @throws Exception 
+   */
+  public void set (String name, String value) throws Exception {
+    if (valByRound.get(name) != null) {
+      throw new Exception("Cannot modify a multi value property!");
+    }
+    props.setProperty(name,value);
+  }
+
+  /**
+   * Return an int property.
+   * If the property contain ":", e.g. "10:100:5", it is interpreted 
+   * as array of ints. It is extracted once, on first call
+   * to get() it, and a by-round-value is returned. 
+   * @param name name of property
+   * @param dflt default value
+   * @return a int property.
+   */
+  public int get (String name, int dflt) {
+    // use value by round if already parsed
+    int vals[] = (int[]) valByRound.get(name);
+    if (vals != null) {
+      return vals[roundNumber % vals.length];
+    }
+    // done if not by round 
+    String sval = props.getProperty(name,""+dflt);
+    if (sval.indexOf(":")<0) {
+      return Integer.parseInt(sval);
+    }
+    // first time this prop is extracted by round
+    int k = sval.indexOf(":");
+    String colName = sval.substring(0,k);
+    sval = sval.substring(k+1);
+    colForValByRound.put(name,colName);
+    vals = propToIntArray(sval);
+    valByRound.put(name,vals);
+    return vals[roundNumber % vals.length];
+  }
+  
+  /**
+   * Return a boolean property.
+   * If the property contain ":", e.g. "true.true.false", it is interpreted 
+   * as array of boleans. It is extracted once, on first call
+   * to get() it, and a by-round-value is returned. 
+   * @param name name of property
+   * @param dflt default value
+   * @return a int property.
+   */
+  public boolean get (String name, boolean dflt) {
+    // use value by round if already parsed
+    boolean vals[] = (boolean[]) valByRound.get(name);
+    if (vals != null) {
+      return vals[roundNumber % vals.length];
+    }
+    // done if not by round 
+    String sval = props.getProperty(name,""+dflt);
+    if (sval.indexOf(":")<0) {
+      return Boolean.valueOf(sval).booleanValue();
+    }
+    // first time this prop is extracted by round 
+    int k = sval.indexOf(":");
+    String colName = sval.substring(0,k);
+    sval = sval.substring(k+1);
+    colForValByRound.put(name,colName);
+    vals = propToBooleanArray(sval);
+    valByRound.put(name,vals);
+    return vals[roundNumber % vals.length];
+  }
+  
+  /**
+   * Increment the round number, for config values that are extracted by round number. 
+   * @return the new round number.
+   */
+  public int newRound () {
+    roundNumber++;
+    
+    // log changes in values
+    if (valByRound.size()>0) {
+      StringBuffer sb = new StringBuffer("--> Round ").append(roundNumber-1).append("-->").append(roundNumber).append(": ");
+      for (Iterator iter = valByRound.keySet().iterator(); iter.hasNext();) {
+        String name = (String) iter.next();
+        Object a = valByRound.get(name);
+        if (a instanceof int[]) {
+          int ai[] = (int[]) a;
+          int n1 = (roundNumber-1)%ai.length;
+          int n2 = roundNumber%ai.length;
+          sb.append("  ").append(name).append(":").append(ai[n1]).append("-->").append(ai[n2]);
+        } else {
+          boolean ab[] = (boolean[]) a;
+          int n1 = (roundNumber-1)%ab.length;
+          int n2 = roundNumber%ab.length;
+          sb.append("  ").append(name).append(":").append(ab[n1]).append("-->").append(ab[n2]);
+        }
+      }
+      System.out.println();
+      System.out.println(sb.toString());
+      System.out.println();
+    }
+    
+    return roundNumber;
+  }
+  
+  // extract properties to array, e.g. for "10.100.5" return int[]{10,100,5}. 
+  private int[] propToIntArray (String s) {
+    if (s.indexOf(":")<0) {
+      return new int [] { Integer.parseInt(s) };
+    }
+    
+    ArrayList a = new ArrayList();
+    StringTokenizer st = new StringTokenizer(s,":");
+    while (st.hasMoreTokens()) {
+      String t = st.nextToken();
+      a.add(new Integer(t));
+    }
+    int res[] = new int[a.size()]; 
+    for (int i=0; i<a.size(); i++) {
+      res[i] = ((Integer) a.get(i)).intValue();
+    }
+    return res;
+  }
+    
+  // extract properties to array, e.g. for "true.true.false" return booleab[]{true,false,false}. 
+  private boolean[] propToBooleanArray (String s) {
+    if (s.indexOf(":")<0) {
+      return new boolean [] { Boolean.valueOf(s).booleanValue() };
+    }
+    
+    ArrayList a = new ArrayList();
+    StringTokenizer st = new StringTokenizer(s,":");
+    while (st.hasMoreTokens()) {
+      String t = st.nextToken();
+      a.add(new Boolean(t));
+    }
+    boolean res[] = new boolean[a.size()]; 
+    for (int i=0; i<a.size(); i++) {
+      res[i] = ((Boolean) a.get(i)).booleanValue();
+    }
+    return res;
+  }
+
+  /**
+   * @return names of params set by round, for reports title
+   */
+  public String getColsNamesForValsByRound() {
+    if (colForValByRound.size()==0) {
+      return "";
+    }
+    StringBuffer sb = new StringBuffer(); 
+    for (Iterator it = colForValByRound.keySet().iterator(); it.hasNext();) {
+      String name = (String) it.next();
+      String colName = (String) colForValByRound.get(name);
+      sb.append(" ").append(colName);
+    }
+    return sb.toString();
+  }
+
+  /**
+   * @return values of params set by round, for reports lines.
+   */
+  public String getColsValuesForValsByRound(int roundNum) {
+    if (colForValByRound.size()==0) {
+      return "";
+    }
+    StringBuffer sb = new StringBuffer(); 
+    for (Iterator it = colForValByRound.keySet().iterator(); it.hasNext();) {
+      String name = (String) it.next();
+      String colName = (String) colForValByRound.get(name);
+      String template = " "+colName;
+      if (roundNum<0) {
+        // just append blanks
+        sb.append(Format.formatPaddLeft("-",template));
+      } else {
+        // append actual values, for that round
+        Object a = valByRound.get(name);
+        if (a instanceof int[]) {
+          int ai[] = (int[]) a;
+          int n = roundNum % ai.length;
+          sb.append(Format.format(ai[n],template));
+        } else {
+          boolean ab[] = (boolean[]) a;
+          int n = roundNum % ab.length;
+          sb.append(Format.formatPaddLeft(""+ab[n],template));
+        }
+      }
+    }
+    return sb.toString();
+  }
+
+  /**
+   * @return the round number.
+   */
+  public int getRoundNumber() {
+    return roundNumber;
+  }
+
+  /**
+   * @return Returns the algorithmText.
+   */
+  public String getAlgorithmText() {
+    return algorithmText;
+  }
+
+}

Added: lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/utils/FileUtils.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/utils/FileUtils.java?view=auto&rev=495834
==============================================================================
--- lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/utils/FileUtils.java (added)
+++ lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/utils/FileUtils.java Fri Jan 12 20:08:23 2007
@@ -0,0 +1,54 @@
+package org.apache.lucene.benchmark.byTask.utils;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * File utilities.
+ */
+public class FileUtils {
+
+  /**
+   * Delete files and directories, even if non-empty.
+   *
+   * @param dir file or directory
+   * @return true on success, false if no or part of files have been deleted
+   * @throws java.io.IOException
+   */
+  public static boolean fullyDelete(File dir) throws IOException {
+    if (dir == null || !dir.exists()) return false;
+    File contents[] = dir.listFiles();
+    if (contents != null) {
+      for (int i = 0; i < contents.length; i++) {
+        if (contents[i].isFile()) {
+          if (!contents[i].delete()) {
+            return false;
+          }
+        } else {
+          if (!fullyDelete(contents[i])) {
+            return false;
+          }
+        }
+      }
+    }
+    return dir.delete();
+  }
+
+}

Added: lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/utils/Format.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/utils/Format.java?view=auto&rev=495834
==============================================================================
--- lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/utils/Format.java (added)
+++ lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/utils/Format.java Fri Jan 12 20:08:23 2007
@@ -0,0 +1,114 @@
+package org.apache.lucene.benchmark.byTask.utils;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.text.NumberFormat;
+
+/**
+ * Formatting utilities (for reports).
+ */
+public class Format {
+
+  private static NumberFormat numFormat [] = { 
+    NumberFormat.getInstance(), 
+    NumberFormat.getInstance(),
+    NumberFormat.getInstance(),
+  };
+  private static final String padd = "                                                 ";
+  
+  static {
+    numFormat[0].setMaximumFractionDigits(0);
+    numFormat[0].setMinimumFractionDigits(0);
+    numFormat[1].setMaximumFractionDigits(1);
+    numFormat[1].setMinimumFractionDigits(1);
+    numFormat[2].setMaximumFractionDigits(2);
+    numFormat[2].setMinimumFractionDigits(2);
+  }
+
+  /**
+   * Padd a number from left.
+   * @param numFracDigits number of digits in fraction part - must be 0 or 1 or 2.
+   * @param f number to be formatted.
+   * @param col column name (used for deciding on length).
+   * @return formatted string.
+   */
+  public static String format(int numFracDigits, float f, String col) {
+    String res = padd + numFormat[numFracDigits].format(f);
+    return res.substring(res.length() - col.length());
+  }
+
+  /**
+   * Padd a number from right.
+   * @param numFracDigits number of digits in fraction part - must be 0 or 1 or 2.
+   * @param f number to be formatted.
+   * @param col column name (used for deciding on length).
+   * @return formatted string.
+   */
+  public static String formatPaddRight(int numFracDigits, float f, String col) {
+    String res = numFormat[numFracDigits].format(f) + padd;
+    return res.substring(0, col.length());
+  }
+
+  /**
+   * Padd a number from left.
+   * @param n number to be formatted.
+   * @param col column name (used for deciding on length).
+   * @return formatted string.
+   */
+  public static String format(int n, String col) {
+    String res = padd + n;
+    return res.substring(res.length() - col.length());
+  }
+
+  /**
+   * Padd a string from right.
+   * @param s string to be formatted.
+   * @param col column name (used for deciding on length).
+   * @return formatted string.
+   */
+  public static String format(String s, String col) {
+    return (s + padd).substring(0, col.length());
+  }
+
+  /**
+   * Padd a string from left.
+   * @param s string to be formatted.
+   * @param col column name (used for deciding on length).
+   * @return formatted string.
+   */
+  public static String formatPaddLeft(String s, String col) {
+    String res = padd + s;
+    return res.substring(res.length() - col.length());
+  }
+
+  /**
+   * Extract simple class name 
+   * @param cls class whose simple name is required 
+   * @return simple class name
+   */
+  public static String simpleName (Class cls) {
+    String c = cls.getName();
+    String p = cls.getPackage().getName();
+    int k = c.lastIndexOf(p+".");
+    if (k<0) {
+      return c;
+    }
+    return c.substring(k+1+p.length());
+  }
+  
+}

Added: lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/utils/package.html
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/utils/package.html?view=auto&rev=495834
==============================================================================
--- lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/utils/package.html (added)
+++ lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/utils/package.html Fri Jan 12 20:08:23 2007
@@ -0,0 +1,5 @@
+<html>
+<body>
+Utilities used for the benchmark, and for the reports.
+</body>
+</html>



Mime
View raw message