--- a/s/BenchmarkInstance.st Fri May 31 12:13:11 2013 +0100
+++ b/s/BenchmarkInstance.st Wed Jun 05 10:45:29 2013 +0100
@@ -12,8 +12,8 @@
!BenchmarkInstance class methodsFor:'instance creation'!
-class: class benchmark: benchmark
- ^self new class: class benchmark: benchmark
+class:class selector:benchmark
+ ^ self new class:class selector:benchmark
"Created: / 27-05-2013 / 19:04:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
@@ -44,103 +44,105 @@
!BenchmarkInstance methodsFor:'accessing'!
-benchmark
- ^ benchmarkSelector
+instance
+ ^ instance
!
-instance
- ^ instance
+selector
+ ^ benchmarkSelector
! !
!BenchmarkInstance methodsFor:'initialization'!
-class: class benchmark: benchmark
- self instance: class new benchmark: benchmark
+class:class selector:benchmark
+ self instance:class new selector:benchmark
"Created: / 27-05-2013 / 19:04:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
-instance: anObject benchmark: aSelector
- | benchmarkMethod annotation |
- (anObject respondsTo: aSelector) ifFalse:[
- self error:'Object does not respond to benchmark (no ', anObject class printString , '>>', aSelector storeString.
+instance:anObject selector:aSelector
+ | benchmarkMethod annotation |
+
+ (anObject respondsTo:aSelector) ifFalse:[
+ self
+ error:'Object does not respond to benchmark (no '
+ , anObject class printString , '>>'
+ , aSelector storeString.
].
-
instance := anObject.
benchmarkSelector := aSelector.
-
- instance class methodDictionary keysAndValuesDo:[:selector :method |
- method numArgs == 0 ifTrue:[
- (method pragmaAt: #setup) notNil ifTrue:[
- setUpSelector1 notNil ifTrue:[
- self error: 'More than one <setup> method'.
+ instance class methodDictionary
+ keysAndValuesDo:[:selector :method |
+ method numArgs == 0 ifTrue:[
+ (method pragmaAt:#setup) notNil ifTrue:[
+ setUpSelector1 notNil ifTrue:[
+ self error:'More than one <setup> method'.
+ ].
+ setUpSelector1 := selector.
].
- setUpSelector1 := selector.
- ].
- (method pragmaAt: #teardown) notNil ifTrue:[
- tearDownSelector1 notNil ifTrue:[
- self error: 'More than one <teardown> method'.
+ (method pragmaAt:#teardown) notNil ifTrue:[
+ tearDownSelector1 notNil ifTrue:[
+ self error:'More than one <teardown> method'.
+ ].
+ tearDownSelector1 := selector.
].
- tearDownSelector1 := selector.
- ].
- (method pragmaAt: #warmup) notNil ifTrue:[
- warmUpSelector1 notNil ifTrue:[
- self error: 'More than one <warmup> method'.
+ (method pragmaAt:#warmup) notNil ifTrue:[
+ warmUpSelector1 notNil ifTrue:[
+ self error:'More than one <warmup> method'.
+ ].
+ warmUpSelector1 := selector.
].
- warmUpSelector1 := selector.
].
].
- ].
-
- benchmarkMethod := instance class compiledMethodAt: benchmarkSelector.
-
- annotation := benchmarkMethod pragmaAt: #setup:.
+ benchmarkMethod := instance class compiledMethodAt:benchmarkSelector.
+ annotation := benchmarkMethod pragmaAt:#setup:.
annotation notNil ifTrue:[
- | method selector |
- selector := annotation argumentAt: 1.
+ | method selector |
+
+ selector := annotation argumentAt:1.
selector isSymbol ifFalse:[
- self error: '<setup:> annotation argument not a symbol'.
+ self error:'<setup:> annotation argument not a symbol'.
].
- method := instance compiledMethodAt: selector ifAbsent: [nil].
+ method := instance compiledMethodAt:selector ifAbsent:[ nil ].
method isNil ifTrue:[
- self error: '<setup:> method does not exist (', selector,')'.
+ self error:'<setup:> method does not exist (' , selector , ')'.
].
method numArgs ~~ 0 ifTrue:[
- self error: '<setup:> method has arguments (', selector,')'.
+ self error:'<setup:> method has arguments (' , selector , ')'.
].
setUpSelector2 := selector.
].
-
- annotation := benchmarkMethod pragmaAt: #teardown:.
+ annotation := benchmarkMethod pragmaAt:#teardown:.
annotation notNil ifTrue:[
- | method selector |
- selector := annotation argumentAt: 1.
+ | method selector |
+
+ selector := annotation argumentAt:1.
selector isSymbol ifFalse:[
- self error: '<teardown:> annotation argument not a symbol'.
+ self error:'<teardown:> annotation argument not a symbol'.
].
- method := instance compiledMethodAt: selector ifAbsent: [nil].
+ method := instance compiledMethodAt:selector ifAbsent:[ nil ].
method isNil ifTrue:[
- self error: '<teardown:> method does not exist (', selector,')'.
+ self error:'<teardown:> method does not exist (' , selector , ')'.
].
method numArgs ~~ 0 ifTrue:[
- self error: '<teardown:> method has arguments (', selector,')'.
+ self error:'<teardown:> method has arguments (' , selector , ')'.
].
tearDownSelector2 := selector.
].
-
- annotation := benchmarkMethod pragmaAt: #warmup:.
+ annotation := benchmarkMethod pragmaAt:#warmup:.
annotation notNil ifTrue:[
- | method selector |
- selector := annotation argumentAt: 1.
+ | method selector |
+
+ selector := annotation argumentAt:1.
selector isSymbol ifFalse:[
- self error: '<warmup:> annotation argument not a symbol'.
+ self error:'<warmup:> annotation argument not a symbol'.
].
- method := instance compiledMethodAt: selector ifAbsent: [nil].
+ method := instance compiledMethodAt:selector ifAbsent:[ nil ].
method isNil ifTrue:[
- self error: '<warmup:> method does not exist (', selector,')'.
+ self error:'<warmup:> method does not exist (' , selector , ')'.
].
method numArgs ~~ 0 ifTrue:[
- self error: '<warmup:> method has arguments (', selector,')'.
+ self error:'<warmup:> method has arguments (' , selector , ')'.
].
warmUpSelector2 := selector.
].
@@ -179,7 +181,7 @@
self setUp.
self setUpParameters:aBenchmarkParameterSet.
self warmUp.
- t := self performBenchmark.
+ t := self benchmark.
] ensure:[ self tearDown. ].
^ t
@@ -195,23 +197,18 @@
!BenchmarkInstance methodsFor:'running-private'!
-performBenchmark
- | t0 t1 |
+benchmark
+ | t0 t1 |
t0 := MillisecondsTime value.
- instance perform: benchmarkSelector.
+ instance perform:benchmarkSelector.
t1 := MillisecondsTime value.
- ^t1 - t0
+ ^ t1 - t0
"Created: / 28-05-2013 / 08:49:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 31-05-2013 / 12:02:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
-performSetUpAnnotatedBy: keyword
-
- "Created: / 28-05-2013 / 08:51:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
setUp
setUpSelector1 notNil ifTrue:[
instance perform: setUpSelector1
@@ -299,10 +296,10 @@
warmed ifFalse:[
instance perform: benchmarkSelector
].
+ ObjectMemory garbageCollect; tenure.
"Created: / 27-05-2013 / 19:02:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 28-05-2013 / 11:00:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified (comment): / 31-05-2013 / 00:30:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 04-06-2013 / 22:19:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!BenchmarkInstance class methodsFor:'documentation'!