jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r1177855 - in /incubator/jena/Experimental/JenaPerf/trunk: classes/ classes/org/ classes/org/apache/ classes/org/apache/jena/ classes/org/apache/jena/perf/ src/main/scala/org/apache/jena/perf/
Date Fri, 30 Sep 2011 22:06:16 GMT
Author: andy
Date: Fri Sep 30 22:06:16 2011
New Revision: 1177855

URL: http://svn.apache.org/viewvc?rev=1177855&view=rev
Log: (empty)

Added:
    incubator/jena/Experimental/JenaPerf/trunk/classes/
    incubator/jena/Experimental/JenaPerf/trunk/classes/org/
    incubator/jena/Experimental/JenaPerf/trunk/classes/org/apache/
    incubator/jena/Experimental/JenaPerf/trunk/classes/org/apache/jena/
    incubator/jena/Experimental/JenaPerf/trunk/classes/org/apache/jena/perf/
    incubator/jena/Experimental/JenaPerf/trunk/src/main/scala/org/apache/jena/perf/PerfUnitLib.scala
Modified:
    incubator/jena/Experimental/JenaPerf/trunk/src/main/scala/org/apache/jena/perf/Actions.scala
    incubator/jena/Experimental/JenaPerf/trunk/src/main/scala/org/apache/jena/perf/PerfMain.scala
    incubator/jena/Experimental/JenaPerf/trunk/src/main/scala/org/apache/jena/perf/PerfUnit.scala

Modified: incubator/jena/Experimental/JenaPerf/trunk/src/main/scala/org/apache/jena/perf/Actions.scala
URL: http://svn.apache.org/viewvc/incubator/jena/Experimental/JenaPerf/trunk/src/main/scala/org/apache/jena/perf/Actions.scala?rev=1177855&r1=1177854&r2=1177855&view=diff
==============================================================================
--- incubator/jena/Experimental/JenaPerf/trunk/src/main/scala/org/apache/jena/perf/Actions.scala
(original)
+++ incubator/jena/Experimental/JenaPerf/trunk/src/main/scala/org/apache/jena/perf/Actions.scala
Fri Sep 30 22:06:16 2011
@@ -7,9 +7,35 @@ import com.hp.hpl.jena.query.QueryExecut
 import com.hp.hpl.jena.tdb.TDBFactory
 import com.hp.hpl.jena.query.Query
 import java.util.Date
+import com.hp.hpl.jena.query.QueryFactory
+import com.hp.hpl.jena.query.Syntax
 
 class Actions {}
 
+trait ActionsBuilder {
+  def actions:List[Action]
+}
+
+class ActionBuilderFile(filename: String) extends ActionsBuilder {
+  def actions: List[Action] = {
+    import scala.io.Source;
+    val lines = Source.fromFile(filename).getLines
+    if ( ! lines.hasNext )
+      return List(new ActionNone("No actions: "+filename))
+    
+    // First line is URI
+    // Then one query file name per line. 
+    val target = lines.next()
+    
+    def proc(str: String): Action = {
+      val query = QueryFactory.read(str, Syntax.syntaxARQ)
+      new ActionByScheme(str, target, query) 
+    }
+    val a = lines.filter(x => !x.isEmpty && ! x.matches("^\\s*#") ).map(proc).toList
+    return a;
+  }
+}
+
 /** Inspect the URI scheme and dispatch to a specific action implementation */ 
 class ActionByScheme(val name: String, uri:String, query:Query) extends ActionQuery {
   self =>
@@ -29,7 +55,7 @@ class ActionByScheme(val name: String, u
 }
 
 /** Support for query on dataset */ 
-trait ActionQuery extends Action {
+abstract class ActionQuery extends Action {
   def exec(ds:Dataset, query:Query) : Result = { 
     import com.hp.hpl.jena.sparql.util.QueryExecUtils
     
@@ -48,6 +74,15 @@ trait ActionQuery extends Action {
   }
 }
 
+// No - need a timing wrapper.
+
+// Sequence of actions with an overall result.
+class ActionSequence(actions: Action*) extends Action {
+  val name = "Seq["+actions.mkString(",")+"]"
+  def perform():Result = {
+    ; null }
+}
+
 /** Action for a querying a local TDB instance */
 class ActionQueryTDB(n:String, location:String, query:Query) extends ActionQuery {
   val name = n+"["+location+"]"

Modified: incubator/jena/Experimental/JenaPerf/trunk/src/main/scala/org/apache/jena/perf/PerfMain.scala
URL: http://svn.apache.org/viewvc/incubator/jena/Experimental/JenaPerf/trunk/src/main/scala/org/apache/jena/perf/PerfMain.scala?rev=1177855&r1=1177854&r2=1177855&view=diff
==============================================================================
--- incubator/jena/Experimental/JenaPerf/trunk/src/main/scala/org/apache/jena/perf/PerfMain.scala
(original)
+++ incubator/jena/Experimental/JenaPerf/trunk/src/main/scala/org/apache/jena/perf/PerfMain.scala
Fri Sep 30 22:06:16 2011
@@ -11,25 +11,30 @@ object PerfMain {
     println("Jena SPARQL Performance test bed")
     println("Start  @ "+now())
 
-    val actions = createActions()
+    val actionBuilder = new ActionBuilderFile("ACTIONS")
+    val actions = actionBuilder.actions 
     val collector = new Collector()
 
-    val runner = new Runner() {
-      def perform(action: Action):Unit = {
-        println(action.name) ;
-        collector.acc(action, action.perform())
-      }
-    }
-
-    val reporter = new Reporter() {
-      def report(collector: Collector): Unit = {
-        println("Acc = "+collector.results.length)
-        for (runUnit <- collector.results) {
-          //println("**"+runUnit.action.name)
-          printf("%s[%d] : %-10s %dms\n", runUnit.name, runUnit.id, runUnit.result.outcome,
runUnit.result.elapsed)
-        }
-      }
-    }
+    val runner = new RunnerCollect(collector)
+    val reporter = new ReporterPrint()
+    
+    
+//    val runner = new Runner() {
+//      def perform(action: Action):Unit = {
+//        println(action.name) ;
+//        collector.acc(action, action.perform())
+//      }
+//    }
+//
+//    val reporter = new Reporter() {
+//      def report(collector: Collector): Unit = {
+//        println("Acc = "+collector.results.length)
+//        for (runUnit <- collector.results) {
+//          //println("**"+runUnit.action.name)
+//          printf("%s[%d] : %-10s %dms\n", runUnit.name, runUnit.id, runUnit.result.outcome,
runUnit.result.elapsed)
+//        }
+//      }
+//    }
     
     enact(actions, runner)
 
@@ -44,7 +49,11 @@ object PerfMain {
 
   val action1 = new ActionByScheme("Q1", "file:D.ttl", query1)
   val action2 = new ActionByScheme("Q2", "tdb:DB", query2)
-  def createActions(): List[Action] = { List(action1, action2) }
+  
+  object ActionBuilderTest extends ActionsBuilder
+  {
+    def actions = List(action1, action2)
+  }
 
   // Performing : Runner
   def enact(actions: List[Action], runner:Runner): Unit =

Modified: incubator/jena/Experimental/JenaPerf/trunk/src/main/scala/org/apache/jena/perf/PerfUnit.scala
URL: http://svn.apache.org/viewvc/incubator/jena/Experimental/JenaPerf/trunk/src/main/scala/org/apache/jena/perf/PerfUnit.scala?rev=1177855&r1=1177854&r2=1177855&view=diff
==============================================================================
--- incubator/jena/Experimental/JenaPerf/trunk/src/main/scala/org/apache/jena/perf/PerfUnit.scala
(original)
+++ incubator/jena/Experimental/JenaPerf/trunk/src/main/scala/org/apache/jena/perf/PerfUnit.scala
Fri Sep 30 22:06:16 2011
@@ -38,11 +38,11 @@ object Result {
 
 object ResultNone extends Result(NoOutcome)
 
-case class RunUnit(name:String, id:Int, action:Action, result:Result)
-
 class Collector {
-  type OneStep = (Action, Result)
-  private val lock:AnyRef = new AnyRef
+  //type OneStep = (Action, Result)
+  case class RunUnit(name:String, id:Int, action:Action, result:Result)
+    
+private val lock:AnyRef = new AnyRef
   private val resultsAcc:ArrayBuffer[RunUnit] = ArrayBuffer.empty
   // Cache.
   private var view:Option[Array[RunUnit]] = None

Added: incubator/jena/Experimental/JenaPerf/trunk/src/main/scala/org/apache/jena/perf/PerfUnitLib.scala
URL: http://svn.apache.org/viewvc/incubator/jena/Experimental/JenaPerf/trunk/src/main/scala/org/apache/jena/perf/PerfUnitLib.scala?rev=1177855&view=auto
==============================================================================
--- incubator/jena/Experimental/JenaPerf/trunk/src/main/scala/org/apache/jena/perf/PerfUnitLib.scala
(added)
+++ incubator/jena/Experimental/JenaPerf/trunk/src/main/scala/org/apache/jena/perf/PerfUnitLib.scala
Fri Sep 30 22:06:16 2011
@@ -0,0 +1,62 @@
+package org.apache.jena.perf
+
+/** A collection of commonly used implementations of PerfUnit interfaces */  
+
+// ---- Runners
+
+object LIB {
+  // alt runner
+  type run = { def perform(action:Action):Unit } 
+}
+
+object RunnerNull extends Runner {
+  def perform(action: Action):Unit = {}
+}
+
+/** Run an action by printing it's name.*/
+class RunnerPrint extends Runner {
+    def perform(action: Action):Unit = println(action.name)
+}
+
+/** Run an action and collect it's results */
+class RunnerCollect(val collector:Collector) extends Runner {
+    def perform(action: Action):Unit = collector.acc(action, action.perform) 
+}
+
+/** Run an action with one runner then run with another. */
+class RunnerChain(runner1:Runner, runner2:Runner) extends Runner {
+    def perform(action: Action):Unit = { 
+      runner1.perform(action)
+      runner2.perform(action)
+    }
+}
+
+//Unnecessary while there is only one method.
+///** Wrap a runner */
+//class RunnerWrapper(runner:Runner) extends Runner {
+//    def perform(action: Action):Unit = runner.perform(action)
+//}
+
+/** Run an action with one runner then run with another. */
+class RunnerDebug(runner:Runner) extends RunnerChain(new RunnerPrint, runner)
+
+///** An action with N times */
+//class ActionN(num:Int, action:Action) extends Action {
+//  def perform():Unit = { 
+//    for(i <- 0 until num)
+//      action.perform()
+//  }
+//}
+
+// ---- Reporters
+
+class ReporterPrint extends Reporter {
+      def report(collector: Collector): Unit = {
+        println("Acc = "+collector.results.length)
+        for (runUnit <- collector.results) {
+          //println("**"+runUnit.action.name)
+          printf("%s[%d] : %-10s %dms\n", runUnit.name, runUnit.id, runUnit.result.outcome,
runUnit.result.elapsed)
+        }
+      }
+  
+}



Mime
View raw message