s/BenchmarkResultC.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Mon, 21 Mar 2016 13:15:35 +0100
changeset 314 9ac0be200068
parent 290 4edd481e1725
child 307 b963ac310a3e
permissions -rw-r--r--
CI: Added CI scripts for Pharo ...to make Jenkins setup easier. To run CalipeL/S tests on Pharo, simply execute: wget -O "ci-pharo-common.sh" https://bitbucket.org/janvrany/jv-calipel/raw/tip/s/pharo/ci/ci-pharo-tests.sh | bash -x To run standard set ob benchmarks on Pharo, run wget -O "ci-pharo-common.sh" https://bitbucket.org/janvrany/jv-calipel/raw/tip/s/pharo/ci/ci-pharo-benchmarks.sh | bash -x

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

"{ NameSpace: Smalltalk }"

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


!BenchmarkResultC class methodsFor:'instance creation'!

new
    "return an initialized instance"

    ^ self basicNew initialize.
! !

!BenchmarkResultC methodsFor:'accessing'!

outcomes
    ^ outcomes
!

outcomesDo: aBlock
    "Iterate outcomes, perform given block.
     outcomes are sorted by benchmark instance name first,
     then by benchmark name"

    ^self outcomesDo: aBlock separatedBy: nil

    "Created: / 11-06-2013 / 23:11:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

outcomesDo: aBlock separatedBy: anotherBlock
    "Iterate outcomes, perform given block.
     outcomes are sorted by benchmark instance name first,
     then by benchmark name"

    | classes classesOutcomes |
    classes := SortedCollection sortBlock:[:a :b|a name < b name].
    classesOutcomes := Dictionary new.
    outcomes do:[:each|
        (classes includes: each benchmark instance class) ifFalse:[
            classes add: each benchmark instance class.
        ].
        (classesOutcomes at: each benchmark instance class ifAbsentPut:[SortedCollection sortBlock:[:a :b|a benchmark selector < b benchmark selector]])
            add: each.
    ].
    classes 
        do:[:class|(classesOutcomes at: class) do: aBlock separatedBy: anotherBlock]
        separatedBy: anotherBlock

    "Created: / 11-06-2013 / 23:37:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

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>"
!

timestamp
    self initializeTimestampIfNotAlready.
    ^ timestamp

    "Created: / 23-06-2013 / 00:54:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 30-09-2015 / 09:04:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!BenchmarkResultC methodsFor:'adding & removing'!

addOutcome: outcome
    outcomes add: outcome

    "Created: / 25-07-2013 / 23:53:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!BenchmarkResultC methodsFor:'initialization'!

initialize
    "Invoked when a new instance is created."

    outcomes := OrderedCollection new.
    runs := 1.

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

initializeTimestamp

    BenchmarkPlatform current isSmalltalkX ifTrue:[
        "Use Smalltalk at: to avoid reference to undeclared
         global in Pharo (so Monticello won't complain)"
        timestamp := (Smalltalk at:#Timestamp) now.
        ^self
    ].
    BenchmarkPlatform current isPharo ifTrue:[
        "Use Smalltalk globals at: to avoid reference to undeclared
         global in Smalltalk/X (so stc won't complain)"
        timestamp := (Smalltalk globals at: #DateAndTime) now.
        ^self
    ].
    self error: 'Unsupported platform'

    "Created: / 23-06-2013 / 00:39:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 30-09-2015 / 09:11:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

initializeTimestampIfNotAlready
    timestamp isNil ifTrue:[
        self initializeTimestamp
    ]

    "Created: / 23-06-2013 / 00:39:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!BenchmarkResultC methodsFor:'inspecting'!

inspector2TabJSON
    <inspector2Tab>

    ^ (self newInspector2Tab)
        label:'JSON report';
        priority:50;
        text: [ String streamContents: [:s | BenchmarkReport json write: self on: s ] ];
        yourself

    "Modified: / 25-11-2014 / 01:07:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

inspector2TabTEXT
    <inspector2Tab>

    ^ (self newInspector2Tab)
        label:'Text report';
        priority:51;
        text: [ String streamContents: [:s | BenchmarkReport text write: self on: s ] ];
        yourself

    "Created: / 25-11-2014 / 01:07:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!BenchmarkResultC 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>"
! !

!BenchmarkResultC 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'
! !