Added BenchmarkExamplesInstrument and class comments on measurement instruments.
This is merely an example on how to use them.
--- a/s/BenchmarkExamples.st Thu Oct 22 08:00:29 2015 +0100
+++ b/s/BenchmarkExamples.st Thu Oct 22 08:25:49 2015 +0100
@@ -9,6 +9,30 @@
category:'CalipeL-S-Core-Examples'
!
+!BenchmarkExamples class methodsFor:'documentation'!
+
+documentation
+"
+ This class provides some examples how to use
+ Calipel/S.
+
+ See https://bitbucket.org/janvrany/jv-calipel/wiki/Writing.md
+ and https://bitbucket.org/janvrany/jv-calipel/wiki/Running.md
+
+ [author:]
+ Jan Vrany <jan.vrany@fit.cvut.cz>
+
+ [instance variables:]
+
+ [class variables:]
+
+ [see also:]
+ https://bitbucket.org/janvrany/jv-calipel/wiki/Writing.md
+ https://bitbucket.org/janvrany/jv-calipel/wiki/Running.md
+
+"
+! !
+
!BenchmarkExamples methodsFor:'examples - 01'!
example01
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/s/BenchmarkExamplesInstrument.st Thu Oct 22 08:25:49 2015 +0100
@@ -0,0 +1,100 @@
+"{ Package: 'jv:calipel/s' }"
+
+"{ NameSpace: Smalltalk }"
+
+Object subclass:#BenchmarkExamplesInstrument
+ instanceVariableNames:'t0 t1'
+ classVariableNames:''
+ poolDictionaries:''
+ category:'CalipeL-S-Core-Examples'
+!
+
+!BenchmarkExamplesInstrument class methodsFor:'documentation'!
+
+documentation
+"
+ This class is an example of a custom measurement instrument.
+ It does measure execution time in seconds.
+
+ Note, that instrument measuring time execution time is
+ included in Calipel by default, this class is merely an
+ example.
+
+ Note, that the value measured by this instrument will differ
+ from the value measured by built-in time measurement since
+ the measurement not performent at the same time. So for short
+ benchmarks like those in BenchmarkExamples the difference will be
+ significant.
+
+ To run BenchmarkExamples with this instrument on, execute:
+
+ | suite executor |
+ suite := BenchmarkSuite class: BenchmarkExamples.
+ executor := BenchmarkExecutor new.
+ executor instruments: { BenchmarkExamplesInstrument new }.
+ suite run: BenchmarkResultC new with: Dictionary new executor: executor.
+
+ For more detailed description of measurement instruments
+ see https://bitbucket.org/janvrany/jv-calipel/wiki/Instruments.md
+
+ [author:]
+ Jan Vrany <jan.vrany@fit.cvut.cz>
+
+ [instance variables:]
+
+ [class variables:]
+
+ [see also:]
+ BenchmarkExecutionTimeInstrument
+ https://bitbucket.org/janvrany/jv-calipel/wiki/Instruments.md
+
+
+"
+! !
+
+!BenchmarkExamplesInstrument methodsFor:'accessing'!
+
+measurementInstrumentName
+ "Returns a human-readable name of this instrument"
+
+ ^ 'Example Time'
+
+ "Created: / 01-12-2014 / 02:36:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 22-10-2015 / 08:05:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+measurementUnit
+ "Return a string describing a unit of this instrument, i.e., msecs
+ for time or '1' for plain counters"
+
+ ^ 's'
+
+ "Created: / 24-11-2014 / 23:47:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 22-10-2015 / 08:05:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!BenchmarkExamplesInstrument methodsFor:'measurement'!
+
+measurementStart:aBenchmarkInstance
+ "superclass BenchmarkMeasurementInstrument says that I am responsible to implement this method"
+
+ t0 := BenchmarkPlatform current millisecondTime
+
+ "Created: / 24-11-2014 / 08:49:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 22-10-2015 / 08:18:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+measurementStop:aBenchmarkInstance
+ t1 := BenchmarkPlatform current millisecondTime
+
+ "Created: / 24-11-2014 / 08:49:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 22-10-2015 / 08:18:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+measurementValue
+ ^ ((t1 - t0) / 1000) asFloat
+
+ "Created: / 24-11-2014 / 08:49:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 22-10-2015 / 08:18:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
--- a/s/BenchmarkExecutionTimeInstrument.st Thu Oct 22 08:00:29 2015 +0100
+++ b/s/BenchmarkExecutionTimeInstrument.st Thu Oct 22 08:25:49 2015 +0100
@@ -46,14 +46,6 @@
"Created: / 24-11-2014 / 23:47:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 25-11-2014 / 01:09:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-name
- "Returns a human-readable name of this instrument"
-
- ^ 'Execution Time'
-
- "Created: / 24-11-2014 / 23:47:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!BenchmarkExecutionTimeInstrument methodsFor:'measurement'!
@@ -77,11 +69,10 @@
!
measurementValue
- "superclass BenchmarkMeasurementInstrument says that I am responsible to implement this method"
-
^ t1 - t0
"Created: / 24-11-2014 / 08:49:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified (comment): / 22-10-2015 / 08:07:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!BenchmarkExecutionTimeInstrument methodsFor:'testing'!
--- a/s/BenchmarkMeasurementInstrument.st Thu Oct 22 08:00:29 2015 +0100
+++ b/s/BenchmarkMeasurementInstrument.st Thu Oct 22 08:25:49 2015 +0100
@@ -19,6 +19,18 @@
One may create a custom instruments and hook them in to measure
custom, application specific aspects.
+ To run BenchmarkExamples with this instrument on, execute following:
+
+ | suite executor |
+
+ suite := BenchmarkSuite class: BenchmarkExamples.
+ executor := BenchmarkExecutor new.
+ executor instruments: { BenchmarkMeasurementInstrument new }.
+ suite run: BenchmarkResultC new with: Dictionary new executor: executor.
+
+ For more detailed description of measurement instruments
+ see https://bitbucket.org/janvrany/jv-calipel/wiki/Instruments.md
+
[author:]
Jan Vrany <jan.vrany@fit.cvut.cz>
@@ -27,6 +39,9 @@
[class variables:]
[see also:]
+ BenchmarkExamplesInstrument
+ https://bitbucket.org/janvrany/jv-calipel/wiki/Instruments.md
+
"
! !
--- a/s/BenchmarkReportJSON.st Thu Oct 22 08:00:29 2015 +0100
+++ b/s/BenchmarkReportJSON.st Thu Oct 22 08:25:49 2015 +0100
@@ -97,7 +97,7 @@
writeMeasurementInstrument: instrument
json writeDictionaryWith:[
- json writeKey: 'name' value: instrument name.
+ json writeKey: 'name' value: instrument measurementInstrumentName.
json writeElementSeparator.
json writeKey: 'class' value: instrument class name.
json writeElementSeparator.
@@ -105,6 +105,7 @@
].
"Created: / 24-11-2014 / 23:46:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 22-10-2015 / 09:11:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
writeMeasurements: measurements
--- a/s/Make.proto Thu Oct 22 08:00:29 2015 +0100
+++ b/s/Make.proto Thu Oct 22 08:25:49 2015 +0100
@@ -124,6 +124,7 @@
$(OUTDIR)Benchmark.$(O) Benchmark.$(H): Benchmark.st $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
$(OUTDIR)BenchmarkError.$(O) BenchmarkError.$(H): BenchmarkError.st $(INCLUDE_TOP)/stx/libbasic/Error.$(H) $(INCLUDE_TOP)/stx/libbasic/Exception.$(H) $(INCLUDE_TOP)/stx/libbasic/GenericException.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
$(OUTDIR)BenchmarkExamples.$(O) BenchmarkExamples.$(H): BenchmarkExamples.st $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
+$(OUTDIR)BenchmarkExamplesInstrument.$(O) BenchmarkExamplesInstrument.$(H): BenchmarkExamplesInstrument.st $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
$(OUTDIR)BenchmarkExecutor.$(O) BenchmarkExecutor.$(H): BenchmarkExecutor.st $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
$(OUTDIR)BenchmarkInstance.$(O) BenchmarkInstance.$(H): BenchmarkInstance.st $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
$(OUTDIR)BenchmarkMeasurement.$(O) BenchmarkMeasurement.$(H): BenchmarkMeasurement.st $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
--- a/s/Make.spec Thu Oct 22 08:00:29 2015 +0100
+++ b/s/Make.spec Thu Oct 22 08:25:49 2015 +0100
@@ -54,6 +54,7 @@
Benchmark \
BenchmarkError \
BenchmarkExamples \
+ BenchmarkExamplesInstrument \
BenchmarkExecutor \
BenchmarkInstance \
BenchmarkMeasurement \
@@ -84,6 +85,7 @@
$(OUTDIR_SLASH)Benchmark.$(O) \
$(OUTDIR_SLASH)BenchmarkError.$(O) \
$(OUTDIR_SLASH)BenchmarkExamples.$(O) \
+ $(OUTDIR_SLASH)BenchmarkExamplesInstrument.$(O) \
$(OUTDIR_SLASH)BenchmarkExecutor.$(O) \
$(OUTDIR_SLASH)BenchmarkInstance.$(O) \
$(OUTDIR_SLASH)BenchmarkMeasurement.$(O) \
--- a/s/abbrev.stc Thu Oct 22 08:00:29 2015 +0100
+++ b/s/abbrev.stc Thu Oct 22 08:25:49 2015 +0100
@@ -4,6 +4,7 @@
Benchmark Benchmark jv:calipel/s 'CalipeL-S-Core' 0
BenchmarkError BenchmarkError jv:calipel/s 'CalipeL-S-Core-Exceptions' 1
BenchmarkExamples BenchmarkExamples jv:calipel/s 'CalipeL-S-Core-Examples' 0
+BenchmarkExamplesInstrument BenchmarkExamplesInstrument jv:calipel/s 'CalipeL-S-Core-Examples' 0
BenchmarkExecutor BenchmarkExecutor jv:calipel/s 'CalipeL-S-Core' 0
BenchmarkInstance BenchmarkInstance jv:calipel/s 'CalipeL-S-Core' 0
BenchmarkMeasurement BenchmarkMeasurement jv:calipel/s 'CalipeL-S-Core-Measurement' 0
--- a/s/bc.mak Thu Oct 22 08:00:29 2015 +0100
+++ b/s/bc.mak Thu Oct 22 08:25:49 2015 +0100
@@ -71,6 +71,7 @@
$(OUTDIR)Benchmark.$(O) Benchmark.$(H): Benchmark.st $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
$(OUTDIR)BenchmarkError.$(O) BenchmarkError.$(H): BenchmarkError.st $(INCLUDE_TOP)\stx\libbasic\Error.$(H) $(INCLUDE_TOP)\stx\libbasic\Exception.$(H) $(INCLUDE_TOP)\stx\libbasic\GenericException.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
$(OUTDIR)BenchmarkExamples.$(O) BenchmarkExamples.$(H): BenchmarkExamples.st $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
+$(OUTDIR)BenchmarkExamplesInstrument.$(O) BenchmarkExamplesInstrument.$(H): BenchmarkExamplesInstrument.st $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
$(OUTDIR)BenchmarkExecutor.$(O) BenchmarkExecutor.$(H): BenchmarkExecutor.st $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
$(OUTDIR)BenchmarkInstance.$(O) BenchmarkInstance.$(H): BenchmarkInstance.st $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
$(OUTDIR)BenchmarkMeasurement.$(O) BenchmarkMeasurement.$(H): BenchmarkMeasurement.st $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
--- a/s/jv_calipel_s.st Thu Oct 22 08:00:29 2015 +0100
+++ b/s/jv_calipel_s.st Thu Oct 22 08:25:49 2015 +0100
@@ -101,6 +101,7 @@
Benchmark
BenchmarkError
BenchmarkExamples
+ BenchmarkExamplesInstrument
BenchmarkExecutor
BenchmarkInstance
BenchmarkMeasurement
--- a/s/libInit.cc Thu Oct 22 08:00:29 2015 +0100
+++ b/s/libInit.cc Thu Oct 22 08:25:49 2015 +0100
@@ -30,6 +30,7 @@
_Benchmark_Init(pass,__pRT__,snd);
_BenchmarkError_Init(pass,__pRT__,snd);
_BenchmarkExamples_Init(pass,__pRT__,snd);
+_BenchmarkExamplesInstrument_Init(pass,__pRT__,snd);
_BenchmarkExecutor_Init(pass,__pRT__,snd);
_BenchmarkInstance_Init(pass,__pRT__,snd);
_BenchmarkMeasurement_Init(pass,__pRT__,snd);
--- a/s/tests/BenchmarkExamplesTests.st Thu Oct 22 08:00:29 2015 +0100
+++ b/s/tests/BenchmarkExamplesTests.st Thu Oct 22 08:25:49 2015 +0100
@@ -9,6 +9,7 @@
category:'CalipeL-S-Tests'
!
+
!BenchmarkExamplesTests methodsFor:'tests'!
testRunAll
@@ -25,5 +26,23 @@
]
"Created: / 15-10-2015 / 16:03:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+testRunWithExampleInstrument
+
+ | suite executor |
+ suite := BenchmarkSuite class: BenchmarkExamples selector: #example01.
+ executor := BenchmarkExecutor new.
+ executor instruments: { BenchmarkExamplesInstrument new }.
+ suite run: BenchmarkResultC new with: Dictionary new executor: executor.
+
+ "Created: / 22-10-2015 / 08:11:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+!BenchmarkExamplesTests class methodsFor:'documentation'!
+
+version_HG
+
+ ^ '$Changeset: <not expanded> $'
+! !
+