s/BenchmarkResult.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Wed, 05 Jun 2013 10:45:29 +0100
changeset 6 25b264cec44e
parent 5 8669edf62d9b
child 12 3a7ebd3da52f
permissions -rw-r--r--
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' }"

Object subclass:#BenchmarkResult
	instanceVariableNames:'outcomes runs'
	classVariableNames:''
	poolDictionaries:''
	category:'CalipeL/S-Core'
!


!BenchmarkResult class methodsFor:'instance creation'!

new
    "return an initialized instance"

    ^ self basicNew initialize.
! !

!BenchmarkResult methodsFor:'accessing'!

outcomes
    ^ outcomes
!

runs
    "Return how many times each benchmark is run." 

    ^ runs

    "Modified (format): / 04-06-2013 / 22:25:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

runs:anInteger
     "Sets how many times each benchmark is run." 

    runs := anInteger.

    "Modified (comment): / 04-06-2013 / 22:25:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!BenchmarkResult methodsFor:'initialization'!

initialize
    "Invoked when a new instance is created."

    outcomes := Set new.
    runs := 1.

    "Modified: / 04-06-2013 / 22:23:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!BenchmarkResult methodsFor:'printing & storing'!

printOn:aStream
    "append a printed representation if the receiver to the argument, aStream"

    aStream nextPutAll: 'Benchmark resut:'; cr.
    BenchmarkReport text write: self on: aStream

    "Modified: / 31-05-2013 / 10:38:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!BenchmarkResult methodsFor:'running-private'!

runBenchmark:aBenchmarkInstance withParameters: aDictionary
    | times |

    times := (1 to: runs) collect: [:i | aBenchmarkInstance runBenchmarkWithParameters: aDictionary].
    outcomes add:
        (BenchmarkOutcome 
            instance: aBenchmarkInstance
            times: times
            parameters: aBenchmarkInstance)

    "Created: / 27-05-2013 / 22:20:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 05-06-2013 / 10:29:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!BenchmarkResult class methodsFor:'documentation'!

version_HG

    ^ '$Changeset: <not expanded> $'
!

version_MC
    ^ 'CalipeL_S-Core-JanVrany.7 5c300a20-c9d7-11e2-a959-606720e43e2c 2013-05-31T10:49:17 JanVrany'
! !