mandelbrot Smalltalk VW program
source code
"* The Computer Language Benchmarks Game
http://benchmarksgame.alioth.debian.org/
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'!
program
| n |
n := CEnvironment commandLine last asNumber.
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® Personal Use Edition Release 8.2 of July 15, 2016
Tue, 02 May 2017 18:44:16 GMT
MAKE:
cp /usr/local/src/vw8.2pul/image/visualnc64.im mandelbrot.vw_run.im
/usr/local/src/vw8.2pul/bin/linuxx86_64/vwlinuxx86_64 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/benchmarksgame_quadcore/mandelbrot/tmp/mandelbrot.vw_run.im created at May 2, 2017 11:43:37 AM
4.27s to complete and log all make actions
COMMAND LINE:
/usr/local/src/vw8.2pul/bin/linuxx86_64/vwlinuxx86_64 mandelbrot.vw_run.im -nogui -evaluate "BenchmarksGame program" -a 16000
(BINARY) PROGRAM OUTPUT NOT SHOWN