2 w@(Integer traits) mandelbrot
4 (File newNamed: 'tests/benchmark/mandelbrot.pbm' &mode: File CreateWrite)
5 sessionDo: [| :f | w mandelbrotOn: f writer]
8 width@(Integer traits) mandelbrotOn: s@(Stream traits)
9 [| isOverLimit bits bitnum |
16 s ; ('P4\n%s %s\n' sprintf*, width, height).
24 cr := 2.0 * (x as: Float) / (width as: Float) - 1.5.
25 ci := 2.0 * (y as: Float) / (height as: Float) - 1.0.
29 tr := (zr * zr) - (zi * zi) + cr.
30 ti := 2.0 * zr * zi + ci.
33 (isOverLimit := (zr * zr) + (zi * zi) > limit2) not
34 /\ [(i += 1) < m]] whileTrue.
36 bits := bits bitShift: 1.
37 isOverLimit ifFalse: [bits += 1].
40 x = (width - 1) ifTrue: [
41 bits := bits bitShift: 8 - bitnum.