s/BenchmarkReportJSON.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Fri, 08 Nov 2013 21:46:50 +0000
changeset 194 55deffb7d7e7
parent 190 ab1b88f52b93
child 195 6bb215884ead
permissions -rw-r--r--
Bug fix in BenchmarkReportJSON>>#writeConfiguration Do not write stray separator in case there's no description (caused JSON to be invalid)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
29
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     1
"{ Package: 'jv:calipel/s' }"
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     2
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     3
BenchmarkReport subclass:#BenchmarkReportJSON
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     4
	instanceVariableNames:'json'
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     5
	classVariableNames:''
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     6
	poolDictionaries:''
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     7
	category:'CalipeL-S-Core-Reports'
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     8
!
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     9
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    10
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    11
!BenchmarkReportJSON methodsFor:'accessing'!
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    12
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    13
stream:something
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    14
    stream := something.
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    15
    json := BenchmarkReportJSONWriter on: stream.
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    16
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    17
    "Created: / 12-06-2013 / 14:22:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    18
! !
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    19
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    20
!BenchmarkReportJSON methodsFor:'writing'!
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    21
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    22
write
89
b37be3ddfeed Added timestamp to BenchmarkResult.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 88
diff changeset
    23
    json writeDictionaryWith:[ 
190
ab1b88f52b93 Added option --description to describe current configuration. --name renamed to --tags.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 180
diff changeset
    24
        json writeKey: 'tags' value: self name.
180
df8e7dcbfd8d Removed --machineid and added --name parameter to identify benchmark run.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 142
diff changeset
    25
        json writeElementSeparator.
89
b37be3ddfeed Added timestamp to BenchmarkResult.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 88
diff changeset
    26
        json writeKey: 'timestamp' value: result timestamp printISO8601.
b37be3ddfeed Added timestamp to BenchmarkResult.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 88
diff changeset
    27
        json writeElementSeparator.
88
7939ec1b572b Added configuration identification into JSON report (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
    28
        json writeKey: 'configuration' valueWith: [ self writeConfiguration ].
7939ec1b572b Added configuration identification into JSON report (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
    29
        json writeElementSeparator.
29
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    30
        json writeKey: 'outcomes' valueWith: [ self writeOutcomes ]
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    31
    ].
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    32
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    33
    "Created: / 12-06-2013 / 14:03:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
190
ab1b88f52b93 Added option --description to describe current configuration. --name renamed to --tags.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 180
diff changeset
    34
    "Modified: / 19-09-2013 / 23:27:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
29
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    35
!
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    36
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    37
writeBenchmark: benchmark
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    38
    json writeDictionaryWith:[
90
af50db15da25 Added name, id and description to benchmark annotation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 89
diff changeset
    39
        json writeKey: 'name' value: benchmark name.
af50db15da25 Added name, id and description to benchmark annotation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 89
diff changeset
    40
        json writeElementSeparator.
af50db15da25 Added name, id and description to benchmark annotation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 89
diff changeset
    41
        json writeKey: 'description' value: benchmark description.
af50db15da25 Added name, id and description to benchmark annotation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 89
diff changeset
    42
        json writeElementSeparator.
29
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    43
        json writeKey: 'class' value: benchmark instance class name.
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    44
        json writeElementSeparator.
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    45
        json writeKey: 'selector' value: benchmark selector.
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    46
    ]
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    47
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    48
    "Created: / 12-06-2013 / 14:10:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
90
af50db15da25 Added name, id and description to benchmark annotation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 89
diff changeset
    49
    "Modified: / 23-06-2013 / 02:27:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
29
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    50
!
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    51
88
7939ec1b572b Added configuration identification into JSON report (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
    52
writeConfiguration
7939ec1b572b Added configuration identification into JSON report (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
    53
    json writeDictionaryWith: [
190
ab1b88f52b93 Added option --description to describe current configuration. --name renamed to --tags.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 180
diff changeset
    54
        description notNil ifTrue:[
ab1b88f52b93 Added option --description to describe current configuration. --name renamed to --tags.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 180
diff changeset
    55
            json writeKey: 'description' value: self description.
194
55deffb7d7e7 Bug fix in BenchmarkReportJSON>>#writeConfiguration
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 190
diff changeset
    56
            json writeElementSeparator.
190
ab1b88f52b93 Added option --description to describe current configuration. --name renamed to --tags.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 180
diff changeset
    57
        ].
88
7939ec1b572b Added configuration identification into JSON report (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
    58
        json writeKey: 'language'   value: 'Smalltalk'.
7939ec1b572b Added configuration identification into JSON report (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
    59
        json writeElementSeparator.
7939ec1b572b Added configuration identification into JSON report (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
    60
        json writeKey: 'runtime'    value: BenchmarkPlatform current configurationStringRuntime.
7939ec1b572b Added configuration identification into JSON report (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
    61
        json writeElementSeparator.
125
1449209198c1 Fixes for machine id handling an JSON output.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 122
diff changeset
    62
        json writeKey: 'os'         value: BenchmarkPlatform current configurationStringOS.
122
9ad7296fc59a Added machine ID configuration value.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 96
diff changeset
    63
        json writeElementSeparator.
180
df8e7dcbfd8d Removed --machineid and added --name parameter to identify benchmark run.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 142
diff changeset
    64
        json writeKey: 'mechineid'   value: (BenchmarkPlatform current configurationStringMachineId)
88
7939ec1b572b Added configuration identification into JSON report (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
    65
    ].
7939ec1b572b Added configuration identification into JSON report (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
    66
7939ec1b572b Added configuration identification into JSON report (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
    67
    "Created: / 22-06-2013 / 22:43:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
194
55deffb7d7e7 Bug fix in BenchmarkReportJSON>>#writeConfiguration
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 190
diff changeset
    68
    "Modified: / 08-11-2013 / 21:45:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
88
7939ec1b572b Added configuration identification into JSON report (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
    69
!
7939ec1b572b Added configuration identification into JSON report (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
    70
29
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    71
writeFooter
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    72
    "superclass BenchmarkReport says that I am responsible to implement this method"
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    73
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    74
    "Modified: / 12-06-2013 / 14:14:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    75
!
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    76
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    77
writeHeader
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    78
    "superclass BenchmarkReport says that I am responsible to implement this method"
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    79
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    80
    "Modified: / 12-06-2013 / 14:14:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    81
!
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    82
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    83
writeOutcome:outcome
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    84
    json writeDictionaryWith:[
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    85
        json writeKey: 'benchmark' valueWith: [ self writeBenchmark: outcome benchmark ].
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    86
        json writeElementSeparator.
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    87
        json writeKey: 'times' value: outcome times.
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    88
        json writeElementSeparator.        
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    89
        json writeKey: 'parameters' valueWith: [ self writeParameters: outcome ].
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    90
    ]
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    91
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    92
    "Modified: / 12-06-2013 / 14:10:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    93
!
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    94
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    95
writeOutcomes
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    96
    "raise an error: must be redefined in concrete subclass(es)"
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    97
    json writeArrayWith:[
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    98
        result 
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    99
           outcomesDo: [:outcome| self writeOutcome: outcome] 
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   100
           separatedBy:[json writeElementSeparator]
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   101
    ]
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   102
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   103
    "Created: / 11-06-2013 / 23:39:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   104
    "Modified (format): / 12-06-2013 / 14:06:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   105
!
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   106
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   107
writeParameters: outcome
142
c69d1eb92d91 Include parameters and their values in JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 125
diff changeset
   108
    json writeDictionaryWith: [
c69d1eb92d91 Include parameters and their values in JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 125
diff changeset
   109
        outcome parameters do:[:paramAndValue |
c69d1eb92d91 Include parameters and their values in JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 125
diff changeset
   110
            json writeKey: paramAndValue key name value: paramAndValue value 
c69d1eb92d91 Include parameters and their values in JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 125
diff changeset
   111
        ] separatedBy:[
c69d1eb92d91 Include parameters and their values in JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 125
diff changeset
   112
            json writeElementSeparator
c69d1eb92d91 Include parameters and their values in JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 125
diff changeset
   113
        ]
c69d1eb92d91 Include parameters and their values in JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 125
diff changeset
   114
    ]
29
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   115
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   116
    "Created: / 12-06-2013 / 14:10:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
142
c69d1eb92d91 Include parameters and their values in JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 125
diff changeset
   117
    "Modified: / 30-07-2013 / 23:58:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
29
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   118
! !
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   119
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   120
!BenchmarkReportJSON class methodsFor:'documentation'!
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   121
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   122
version_HG
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   123
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   124
    ^ '$Changeset: <not expanded> $'
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   125
! !
00d2eaa41853 Initial version of JSON report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   126