Skip to content

Commit

Permalink
Add more microbenchmarks to assess interpreter performance (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
smarr authored Jun 16, 2024
2 parents 312d77a + 0595f30 commit 9c04914
Show file tree
Hide file tree
Showing 21 changed files with 1,108 additions and 360 deletions.
77 changes: 77 additions & 0 deletions Examples/Benchmarks/Interpreter/ArgRead.som
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
"
Copyright (c) 2024 see AUTHORS file

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the 'Software'), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
"

"Microbenchmark: reading a method argument"
ArgRead = Benchmark (
benchmark = (
^ self benchmark: 0
)

benchmark: counter = ( | iter |
iter := 20000.

[ iter > 0 ] whileTrue: [
iter := iter - 1.
counter.
counter.
counter.
counter.
counter.

counter.
counter.
counter.
counter.
counter.

counter.
counter.
counter.
counter.
counter.

counter.
counter.
counter.
counter.
counter.

counter.
counter.
counter.
counter.
counter.

counter.
counter.
counter.
counter.
counter.
].

^ counter
)

verifyResult: result = (
^ 0 = result
)
)
74 changes: 74 additions & 0 deletions Examples/Benchmarks/Interpreter/ArrayReadConst.som
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
"
Copyright (c) 2024 see AUTHORS file

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the 'Software'), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
"

"Microbenchmark: measure reading an array at contant index"
ArrayReadConst = Benchmark (
benchmark = ( | arr iter |
arr := #(42).
iter := 20000.

[ iter > 0 ] whileTrue: [
iter := iter - 1.
arr at: 1.
arr at: 1.
arr at: 1.
arr at: 1.
arr at: 1.

arr at: 1.
arr at: 1.
arr at: 1.
arr at: 1.
arr at: 1.

arr at: 1.
arr at: 1.
arr at: 1.
arr at: 1.
arr at: 1.

arr at: 1.
arr at: 1.
arr at: 1.
arr at: 1.
arr at: 1.

arr at: 1.
arr at: 1.
arr at: 1.
arr at: 1.
arr at: 1.

arr at: 1.
arr at: 1.
arr at: 1.
arr at: 1.
arr at: 1.
].

^ arr at: 1
)

verifyResult: result = (
^ 42 = result
)
)
74 changes: 74 additions & 0 deletions Examples/Benchmarks/Interpreter/ArrayWriteConstConst.som
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
"
Copyright (c) 2024 see AUTHORS file

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the 'Software'), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
"

"Microbenchmark: writing a constant to an array at contant index"
ArrayWriteConstConst = Benchmark (
benchmark = ( | arr iter |
arr := #(42).
iter := 20000.

[ iter > 0 ] whileTrue: [
iter := iter - 1.
arr at: 1 put: 2.
arr at: 1 put: 2.
arr at: 1 put: 2.
arr at: 1 put: 2.
arr at: 1 put: 2.

arr at: 1 put: 2.
arr at: 1 put: 2.
arr at: 1 put: 2.
arr at: 1 put: 2.
arr at: 1 put: 2.

arr at: 1 put: 2.
arr at: 1 put: 2.
arr at: 1 put: 2.
arr at: 1 put: 2.
arr at: 1 put: 2.

arr at: 1 put: 2.
arr at: 1 put: 2.
arr at: 1 put: 2.
arr at: 1 put: 2.
arr at: 1 put: 2.

arr at: 1 put: 2.
arr at: 1 put: 2.
arr at: 1 put: 2.
arr at: 1 put: 2.
arr at: 1 put: 2.

arr at: 1 put: 2.
arr at: 1 put: 2.
arr at: 1 put: 2.
arr at: 1 put: 2.
arr at: 1 put: 2.
].

^ arr at: 1
)

verifyResult: result = (
^ 2 = result
)
)
73 changes: 73 additions & 0 deletions Examples/Benchmarks/Interpreter/BlockSend0ConstReturn.som
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
"
Copyright (c) 2024 see AUTHORS file

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the 'Software'), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
"

"Microbenchmark: activating a block that evaluates to constant"
BlockSend0ConstReturn = Benchmark (
benchmark = ( | iter |
iter := 20000.

[ iter > 0 ] whileTrue: [
iter := iter - 1.
[ 0 ] value.
[ 0 ] value.
[ 0 ] value.
[ 0 ] value.
[ 0 ] value.

[ 0 ] value.
[ 0 ] value.
[ 0 ] value.
[ 0 ] value.
[ 0 ] value.

[ 0 ] value.
[ 0 ] value.
[ 0 ] value.
[ 0 ] value.
[ 0 ] value.

[ 0 ] value.
[ 0 ] value.
[ 0 ] value.
[ 0 ] value.
[ 0 ] value.

[ 0 ] value.
[ 0 ] value.
[ 0 ] value.
[ 0 ] value.
[ 0 ] value.

[ 0 ] value.
[ 0 ] value.
[ 0 ] value.
[ 0 ] value.
[ 0 ] value.
].

^ [ 0 ] value
)

verifyResult: result = (
^ 0 = result
)
)
73 changes: 73 additions & 0 deletions Examples/Benchmarks/Interpreter/Const.som
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
"
Copyright (c) 2024 see AUTHORS file

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the 'Software'), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
"

"Microbenchmark: reading a literal"
Const = Benchmark (
benchmark = ( | iter |
iter := 20000.

[ iter > 0 ] whileTrue: [
iter := iter - 1.
42.
42.
42.
42.
42.

42.
42.
42.
42.
42.

42.
42.
42.
42.
42.

42.
42.
42.
42.
42.

42.
42.
42.
42.
42.

42.
42.
42.
42.
42.
].

^ 42
)

verifyResult: result = (
^ 42 = result
)
)
Loading

0 comments on commit 9c04914

Please sign in to comment.