Added parameter to BenchmarkResult to run each benchmark multiple times.
The BenchmarkOutcome keeps all times. Also, BenchmarkInstance>>benchmark
renamed to selector.
"{ Package: 'jv:calipel/s/tests' }"
TestCase subclass:#BenchmarkInstanceTests
instanceVariableNames:'log param1 param2'
classVariableNames:''
poolDictionaries:''
category:'CalipeL/S-Tests'
!
!BenchmarkInstanceTests methodsFor:'accessing-parameters'!
param1
^ param1
!
param1:anInteger
<parameter: Integer>
param1 := anInteger.
"Modified: / 27-05-2013 / 23:40:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
param2
^ param2
!
param2:anInteger
<parameter: Integer values: #(1234 9876)>
param2 := anInteger.
"Modified: / 28-05-2013 / 00:13:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!BenchmarkInstanceTests methodsFor:'benchmarks'!
bench_01
<benchmark>
log add: #bench_01
"Created: / 27-05-2013 / 22:08:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
bench_02
<benchmark>
log add: #bench_02 add: param1
"Created: / 27-05-2013 / 23:28:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
bench_setUp
<setup>
log add: #bench_setUp
"Created: / 28-05-2013 / 08:34:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!BenchmarkInstanceTests methodsFor:'running'!
setUp
log := OrderedCollection new.
"Created: / 27-05-2013 / 22:08:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!BenchmarkInstanceTests methodsFor:'tests'!
test_01
| b r |
b := BenchmarkInstance new instance:self selector:#'bench_01'.
r := b run.
self assert: r outcomes size == 1.
self assert: r outcomes first instance == b.
self assert: log asArray = #(#bench_setUp #bench_01 "default warmup" #bench_01).
"Created: / 27-05-2013 / 22:08:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 28-05-2013 / 11:02:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
test_02
self
should: [BenchmarkInstance class:self class selector:#'non_existent_benchmark']
raise: Error
"Created: / 27-05-2013 / 22:13:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
test_03a
| b r |
b := BenchmarkInstance new instance:self selector:#'bench_01'.
r := b runWith: Dictionary new.
self assert: param1 isNil
"Created: / 28-05-2013 / 00:04:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
test_03b
| b r |
b := BenchmarkInstance new instance:self selector:#'bench_01'.
r := b runWith: (Dictionary new at: #param1 put: '1234'; yourself).
self assert: param1 == 1234
"Created: / 28-05-2013 / 00:05:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
test_03c
| b r |
b := BenchmarkInstance new instance:self selector:#'bench_01'.
r := b runWith: (Dictionary new at: #'BenchmarkInstanceTests#param1' put: '1234'; yourself).
self assert: param1 == 1234
"Created: / 28-05-2013 / 00:05:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
test_03d
| b r |
b := BenchmarkInstance new instance:self selector:#'bench_01'.
r := b runWith: (Dictionary new
at: #'param1' put: '9876';
at: #'BenchmarkInstanceTests#param1' put: '1234'; yourself).
self assert: param1 == 1234
"Created: / 28-05-2013 / 00:06:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
test_03e
| b |
b := BenchmarkInstance new instance:self selector:#'bench_01'.
self should: [
b runWith: (Dictionary new
at: #'param2' put: '5555'; yourself).
] raise: Error.
"Created: / 28-05-2013 / 00:11:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
test_03f
| b |
b := BenchmarkInstance new instance:self selector:#'bench_01'.
self should: [
b runWith: (Dictionary new
at: #'param1' put: 'asdf'; yourself).
] raise: Error.
"Created: / 28-05-2013 / 00:12:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!BenchmarkInstanceTests class methodsFor:'documentation'!
version_HG
^ '$Changeset: <not expanded> $'
! !