Skip to content

Commit

Permalink
Reimplement All as benchmark
Browse files Browse the repository at this point in the history
It’s run with the normal harness.
Though, it needs a long classpath:

 -cp Smalltalk:Examples/Benchmarks/TestSuite:Examples/Benchmarks/Richards:Examples/Benchmarks/DeltaBlue:Examples/Benchmarks/NBody:Examples/Benchmarks/Json:Examples/Benchmarks/GraphSearch:Examples/Benchmarks/LanguageFeatures Examples/Benchmarks/BenchmarkHarness.som All 3 10

Signed-off-by: Stefan Marr <[email protected]>
  • Loading branch information
smarr committed Aug 13, 2024
1 parent 9c04914 commit ebe3884
Showing 1 changed file with 46 additions and 52 deletions.
98 changes: 46 additions & 52 deletions Examples/Benchmarks/All.som
Original file line number Diff line number Diff line change
Expand Up @@ -20,63 +20,57 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
"

All = BenchmarkHarness (
| summedAverage |
All = Benchmark (
oneTimeSetup = (
self all do: [:pair |
system load: (pair at: 1)
]
)

all = (
^ Fibonacci, Dispatch, Bounce, Loop, Permute, Queens, List, Recurse,
Storage, Sieve, BubbleSort, QuickSort, Sum, Towers, TreeSort,
IntegerLoop, FieldLoop
)

run: params = (
params length < 2
ifTrue: [ self exec: 100 ]
ifFalse: [ self exec: (params at: 2) asInteger ]
)

printUsage = (
'./som.sh -cp Smalltalk Examples/Benchmarks/All.som [number-of-iterations]' println.
'' println.
' number-of-iterations - the number of time each benchmark is executed, default: 1' println.
)

initialize = (
super initialize.
summedAverage := 0.
^ #(#Richards 1),
#(#DeltaBlue 100),
#(#NBody 1000),
#(#Json 1),
#(#GraphSearch 7),
#(#PageRank 75),
#(#Fannkuch 7),
#(#Fibonacci 10),
#(#Dispatch 10),
#(#Bounce 10),
#(#Loop 100),
#(#Permute 10),
#(#Queens 10),
#(#List 2),
#(#Recurse 12),
#(#Storage 8),
#(#Sieve 20),
#(#BubbleSort 15),
#(#QuickSort 15),
#(#Sum 40),
#(#Towers 2),
#(#TreeSort 7),
#(#IntegerLoop 7),
#(#FieldLoop 1),
#(#WhileLoop 30),
#(#Mandelbrot 50),
#(#Test 1)
)

exec: iterations = (
'Start execution of all benchmarks. Iterations: ' print.
iterations println.

self all do: [:cls |
self initialize.
self benchmarkClass: cls.
self printAll: false.
self maxRuntime: 3. "seconds"
self numIterations: iterations.
self warmUp: 10.

self runBenchmark.
benchmark = (
self all do: [:pair |
| benchName size benchClass bench |
benchName := pair at: 1.
size := pair at: 2.

benchClass := system load: benchName.
bench := benchClass new.
bench oneTimeSetup.
(bench innerBenchmarkLoop: size) ifFalse: [
self error: benchName + ' failed with incorrect result' ].
].
self printTotal.
^ true
)

reportBenchmark: bench result: total = (
'' println.
'Benchmark: ' print.
bench name println.

(' Iterations: ' + numIterations + ' (elapsed time ' + (total // 1000) round
+ ' ms)') println.
(' AVERAGE: ' + ((total // numIterations) // 1000) round + ' ms') println.

summedAverage := summedAverage + (total // numIterations).
)

printTotal = (
('Summed Average Runtime: ' + (summedAverage // 1000) round asString + ' ms') println.
)

verifyResult: result = ( ^ result )
)

0 comments on commit ebe3884

Please sign in to comment.