mandelbrot VW Smalltalk program
source code
"* The Computer Language Benchmarks Game
https://salsa.debian.org/benchmarksgame-team/benchmarksgame/
contributed by Paolo Bonzini
reworked by Isaac Gouy *"!
Smalltalk.Core defineClass: #BenchmarksGame
superclass: #{Core.Object}
indexedType: #none
private: false
instanceVariableNames: ''
classInstanceVariableNames: ''
imports: ''
category: ''!
!Core.BenchmarksGame class methodsFor: 'private'!
mandelbrot: extent to: output
| limit2 m bits zr zi cr ci i tr stepr stepi |
limit2 := 4.0d0.
m := 50.
stepr := 2.0d0 / extent.
stepi := 2.0d0 / extent.
0 to: extent - 1 do: [ :y |
bits := 0.
ci := stepi * y asFloat - 1.0d0.
0 to: extent - 1 do: [ :x |
cr := stepr * x asFloat - 1.5d0.
zr := cr. zi := ci.
bits := bits bitShift: 1.
i := 1.
[
tr := (zr*zr) - (zi*zi) + cr.
zi := 2.0d0 * zr * zi + ci.
zr := tr.
(zr*zr) + (zi*zi) < limit2 and: [ (i := i + 1) < m ]
] whileTrue.
i = m ifTrue: [ bits := bits + 1 ].
(x bitAnd: 7) == 7 ifTrue: [
output nextPut: bits.
bits := 0.
]
].
(extent bitAnd: 7) == 0 ifFalse: [
bits := bits bitShift: 8 - (extent bitAnd: 7).
output nextPut: bits.
]
]! !
!Core.BenchmarksGame class methodsFor: 'initialize-release'!
do: n
Stdout
nextPutAll: 'P4'; nl;
print: n; space; print: n; nl;
binary.
self mandelbrot: n to: Stdout.
^''! !
!Core.Stream methodsFor: 'benchmarks game'!
nl
self nextPut: Character lf! !
notes, command-line, and program output
NOTES:
64-bit Ubuntu quad core
VisualWorks® 8.3
Aug 19 2017
Wed, 29 May 2024 00:54:46 GMT
MAKE:
cp /opt/src/vw8.3pul/image/visualnc64.im mandelbrot.vw_run.im
/opt/src/vw8.3pul/bin/visual mandelbrot.vw_run.im -nogui -pcl MatriX -filein mandelbrot.vw -doit 'ObjectMemory snapshotThenQuit'
Autoloading MatriX from $(VISUALWORKS)/preview/matrix/MatriX.pcl
Autoloading Xtreams-Support from $(VISUALWORKS)/xtreams/Xtreams-Support.pcl
Autoloading Xtreams-Core from $(VISUALWORKS)/xtreams/Xtreams-Core.pcl
Autoloading Xtreams-Terminals from $(VISUALWORKS)/xtreams/Xtreams-Terminals.pcl
Autoloading Xtreams-Transforms from $(VISUALWORKS)/xtreams/Xtreams-Transforms.pcl
Autoloading Xtreams-Substreams from $(VISUALWORKS)/xtreams/Xtreams-Substreams.pcl
Autoloading Xtreams-Multiplexing from $(VISUALWORKS)/xtreams/Xtreams-Multiplexing.pcl
Filing in from:
mandelbrot.vw
BenchmarksGame class<private
BenchmarksGame class<initialize-release
Stream<benchmarks game
Do you want to add Root.Smalltalk.Core.Stream>>nl to the previously unchanged package, Collections-Streams
OK to continue?
/home/dunham/all-benchmarksgame/benchmarksgame_i53330/mandelbrot/tmp/mandelbrot.vw_run.im created at May 28, 2024 5:54:21 PM
7.51s to complete and log all make actions
COMMAND LINE:
/opt/src/vw8.3pul/bin/visual mandelbrot.vw_run.im -nogui -evaluate "BenchmarksGame do: 16000"
(BINARY) PROGRAM OUTPUT NOT SHOWN