Skip to content

Commit

Permalink
copy from smart_pointer branch
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel.hefenbrock committed May 2, 2009
1 parent 6dbe898 commit 7d49fd1
Show file tree
Hide file tree
Showing 191 changed files with 19,036 additions and 0 deletions.
40 changes: 40 additions & 0 deletions Examples/Benchmarks/All.som
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
"

$Id: All.som 286 2008-05-09 22:38:14Z daniel.richter $

Copyright (c) 2001-2007 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.
"

All = (

run = (
| total |
total := 0.

Fibonacci, Dispatch, Bounce, Loop, Permute, Queens, List, Recurse,
Storage, Sieve, BubbleSort, QuickSort, Sum, Towers, TreeSort,
IntegerLoop
do: [ :benchmark | total := total + benchmark new run ].

('All tests completed (' + total + ' ms)') println.
)

)
59 changes: 59 additions & 0 deletions Examples/Benchmarks/Ball.som
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
"

$Id: Ball.som 92 2007-09-06 09:23:43Z tobias.pape $

Copyright (c) 2001-2007 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.
"

Ball = (

| x y xVel yVel |

bounce = (
| xLimit yLimit bounced |
xLimit := yLimit := 500.
bounced := false.

x := x + xVel.
y := y + yVel.
(x > xLimit)
ifTrue: [ x := xLimit. xVel := 0 - xVel abs. bounced := true ].
(x < 0)
ifTrue: [ x := 0. xVel := xVel abs. bounced := true ].
(y > yLimit)
ifTrue: [ y := yLimit. yVel := 0 - yVel abs. bounced := true ].
(y < 0)
ifTrue: [ y := 0. yVel := yVel abs. bounced := true ].
^bounced
)

initialize = (
x := Random next % 500.
y := Random next % 500.
xVel := (Random next % 300) - 150.
yVel := (Random next % 300) - 150.
)

-----------------

new = ( ^super new initialize )

)
50 changes: 50 additions & 0 deletions Examples/Benchmarks/Benchmark.som
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
"

$Id: Benchmark.som 526 2008-05-28 20:58:38Z daniel.richter $

Copyright (c) 2001-2007 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.
"

Benchmark = (

run = (
| startTime elapsedTime averageTime iterations |

(('Starting ' + (self name)) + ' benchmark ... ') println.

iterations := elapsedTime := 0.
startTime := system time.

[ elapsedTime < 2000 ]
whileTrue: [
self benchmark.
iterations := iterations + 1.
elapsedTime := system time - startTime. ].

averageTime := elapsedTime / iterations.
(' Completed (' + averageTime + ' ms)') println. '' println.
^averageTime
)

benchmark = ( self subclassResponsibility )
name = ( ^self class name asString )

)
46 changes: 46 additions & 0 deletions Examples/Benchmarks/Bounce.som
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
"

$Id: Bounce.som 92 2007-09-06 09:23:43Z tobias.pape $

Copyright (c) 2001-2007 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.
"

Bounce = Benchmark (

benchmark = (
| ballCount balls bounces |

Random initialize.

ballCount := 100.
bounces := 0.
balls := Array new: ballCount withAll: [ Ball new ].

1 to: 50 do: [ :i |
balls do: [ :ball |
(ball bounce) ifTrue: [ bounces := bounces + 1 ] ] ].

(bounces = 1331)
ifFalse: [
self error: 'Wrong result: ' + bounces + ' should be: 1331' ]
)

)
46 changes: 46 additions & 0 deletions Examples/Benchmarks/BubbleSort.som
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
"

$Id: BubbleSort.som 223 2008-04-21 11:48:41Z michael.haupt $

Copyright (c) 2001-2007 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.
"

BubbleSort = Sort (

sort: array = (
| top |

"array length - 1 downTo: 0 do: [ :i |
0 to: i - 1 do: [ :j |"
array length downTo: 1 do: [ :i |
1 to: i - 1 do: [ :j |
| current next |
current := array at: j.
next := array at: j + 1.
(current > next)
ifTrue: [
array at: j put: next.
array at: j + 1 put: current ] ] ]
)

dataSize = ( ^130 )

)
34 changes: 34 additions & 0 deletions Examples/Benchmarks/Dispatch.som
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"

$Id: Dispatch.som 92 2007-09-06 09:23:43Z tobias.pape $

Copyright (c) 2001-2007 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.
"

Dispatch = Benchmark (

benchmark = (
1 to: 20000 do: [ :i | self method: i ]
)

method: argument = ( ^argument )

)
41 changes: 41 additions & 0 deletions Examples/Benchmarks/Fibonacci.som
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
"

$Id: Fibonacci.som 92 2007-09-06 09:23:43Z tobias.pape $

Copyright (c) 2001-2007 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.
"

Fibonacci = Benchmark (

benchmark = ( | result |
result := self fibonacci: 20.
(result = 10946)
ifFalse: [
self error: 'Wrong result: ' + result + ' should be: 10946' ]
)

fibonacci: n = (
^(n <= 1)
ifTrue: 1
ifFalse: [ (self fibonacci: (n - 1)) + (self fibonacci: (n - 2)) ]
)

)
34 changes: 34 additions & 0 deletions Examples/Benchmarks/IntegerLoop.som
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"

$Id: List.som 92 2007-09-06 09:23:43Z tobias.pape $

Copyright (c) 2001-2007 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.
"

IntegerLoop = Benchmark (

benchmark = ( | bounds |

bounds := 20000.

bounds negated to: bounds by: 1 do: [:value | |a| a := value-value].
)
)
Loading

0 comments on commit 7d49fd1

Please sign in to comment.