Skip to content

Commit

Permalink
Refactor object test initialization.
Browse files Browse the repository at this point in the history
  • Loading branch information
Aleksandar Prokopec committed Nov 10, 2012
1 parent 97b8467 commit e14843b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
target
project/target
tmp*


*.*~
14 changes: 7 additions & 7 deletions src/main/scala/org/scalameter/PerformanceTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ import utils.Tree
abstract class PerformanceTest extends PerformanceTest.Initialization {

def main(args: Array[String]) {
Main.main(args :+ "-benches" :+ this.getClass.getName)
val ctx = Main.Configuration.fromCommandLineArgs(args).context
dyn.initialContext.withValue(ctx) {
executeTests()
}
}

}
Expand All @@ -27,10 +30,8 @@ object PerformanceTest {
def reporter: org.scalameter.Reporter

def persistor: Persistor

protected def initSetupTree() {
setupzipper.value = setupzipper.value.addContext(Key.dsl.executor -> executor.toString)
}

setupzipper.value = setupzipper.value.addContext(Key.dsl.executor -> executor.toString)

type SameType

Expand All @@ -45,8 +46,7 @@ object PerformanceTest {
}

def delayedInit(body: =>Unit) {
if (!DSL.withinInclude.value) {
initSetupTree()
if (!withinInclude.value) {
body
executeTests()
} else body
Expand Down
20 changes: 10 additions & 10 deletions src/main/scala/org/scalameter/dsl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ trait DSL {

import DSL._

private[scalameter] val withinInclude = new DynamicVariable(this.getClass.getName.endsWith("$"))

private[scalameter] val setupzipper = new DynamicVariable(Tree.Zipper.root[Setup[_]])

private[scalameter] def descendInScope(name: String, context: Context)(body: =>Unit) {
setupzipper.value = setupzipper.value.descend.setContext(context)
body
setupzipper.value = setupzipper.value.ascend
}

object performance {
def of(modulename: String) = Scope(modulename, setupzipper.value.current.context)
}
Expand Down Expand Up @@ -53,16 +63,6 @@ trait DSL {

object DSL {

private[scalameter] val withinInclude = new DynamicVariable(false)

private[scalameter] val setupzipper = new DynamicVariable(Tree.Zipper.root[Setup[_]])

private[scalameter] def descendInScope(name: String, context: Context)(body: =>Unit) {
setupzipper.value = setupzipper.value.descend.setContext(context)
body
setupzipper.value = setupzipper.value.ascend
}

private[scalameter] val curveNameCount = new java.util.concurrent.atomic.AtomicInteger(0)

private[scalameter] def freshCurveName(): String = "Test-" + curveNameCount.getAndIncrement()
Expand Down

0 comments on commit e14843b

Please sign in to comment.