s/BenchmarkRunnerExecutor.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Fri, 25 Sep 2015 05:18:26 +0100
changeset 285 0cf54ee76de5
parent 268 ee1fd4a6e836
child 302 30fc156ff773
permissions -rw-r--r--
Normalized Windows OS identification string with Pharo

"{ Package: 'jv:calipel/s' }"

"{ NameSpace: Smalltalk }"

BenchmarkExecutor subclass:#BenchmarkRunnerExecutor
	instanceVariableNames:'transcript'
	classVariableNames:''
	poolDictionaries:''
	category:'CalipeL-S-Core-Runner'
!

!BenchmarkRunnerExecutor class methodsFor:'documentation'!

documentation
" 
 
  Replace 'Object', 'NewClass1' and
  the empty string arguments by true values.
 
  Install (or change) the class by 'accepting',
  either via the menu or the keyboard (usually CMD-A).
 
  You can also change the category simply by editing
  the categoryString and accepting.
 
  To be nice to others (and yourself later), do not forget to
  add some documentation; preferably under the classes documentation
  protocol.
  (see the `create documentation stubs' item in the methodList menu;
   switch from instance to class to find this menu item.)
 
  Notice, that ST/X uses the convention to document the class using
  comment-only class methods (however, ST80 comments are supported and
  can be changed via the class-documentation menu).
 
 
 
  Notice: 
    the above text has been extracted from the classes documentation method.
    Any change in it will be lost if you 'accept' here.
    To change the documentation, switch to the documentation method and 'accept' any changes there.
 
"
! !

!BenchmarkRunnerExecutor class methodsFor:'instance creation'!

new
    "return an initialized instance"

    ^ self basicNew initialize.
! !

!BenchmarkRunnerExecutor methodsFor:'executing-private'!

benchmark: aBenchmarkInstance
    transcript nextPutAll: 'B..'.
    ^super benchmark: aBenchmarkInstance.

    "Created: / 24-11-2014 / 00:18:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

execute: aBenchmarkInstance result: aBenchmarkResult parameters: aCollection
    | nm outcome |

    nm := aBenchmarkInstance name.
    transcript next: (25 - nm size) put: Character space.
    transcript nextPutAll: nm.
    transcript nextPutAll: '...'.

    [
        outcome := super execute: aBenchmarkInstance result: aBenchmarkResult 
        parameters: aCollection.
	    outcome notNil ifTrue:[
            transcript nextPutAll: 'OK ['.
            transcript nextPutAll: outcome time printString.
            transcript nextPutAll: ']'.
            aCollection notEmpty ifTrue:[        
                transcript nextPutAll: ' {'.
                (aCollection asSortedCollection:[:a :b | a key name < b key name ]) do:[:paramAndValue|
                    transcript nextPutAll: paramAndValue key name.
                    transcript nextPutAll: '='.        
                    transcript nextPutAll: paramAndValue value storeString.
                ] separatedBy:[
                    transcript nextPutAll: ', '.            
                ].
                transcript nextPutAll: '}'.
            ].
        ] ifFalse:[
            transcript nextPutAll: 'SKIPPED'.
        ].
        transcript nextPutAll: '
'.
    ] on: BenchmarkExecutionError do:[:ex|
        transcript nextPutAll:  '!!!!!! ERROR: '.
        transcript nextPutAll: ex description.
        transcript nextPutAll:'
'.
        ex pass.
    ].
    ^ outcome

    "Created: / 27-07-2013 / 12:33:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 21-08-2013 / 14:58:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

setUp:aBenchmarkInstance parameters: aCollection
    transcript nextPutAll:'S..'.   
    aCollection do:[:each|
        aBenchmarkInstance setUpParameter: each key value: each value
    ].
    aBenchmarkInstance setUp.

    "Created: / 27-07-2013 / 12:33:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

tearDown: aBenchmarkInstance
    transcript nextPutAll: 'T..'.
    super tearDown: aBenchmarkInstance

    "Created: / 24-06-2013 / 01:21:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

warmUp: aBenchmarkInstance
    transcript nextPutAll: 'W..'.
    super warmUp: aBenchmarkInstance.

    "Created: / 24-06-2013 / 01:21:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!BenchmarkRunnerExecutor methodsFor:'initialization'!

initialize
    "Invoked when a new instance is created."

    super initialize.
    transcript := BenchmarkPlatform current stderr.
    (Smalltalk isSmalltalkX and:[Transcript isView]) ifTrue:[
        transcript := Transcript
    ].

    "Created: / 24-06-2013 / 01:16:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!BenchmarkRunnerExecutor class methodsFor:'documentation'!

version_HG

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