Hi Hilaire,

Do you have to use the world or Morphic at all ?

I wrote 2 different real-time 2D games at 50fps in Pharo [1,2]. I tried
using Morphic but that was crazy slow I could not even get 20fps. Instead I
use direct bindings to Cairo surface and SDL2 window and I don't open the
world morph at all to avoid the delays due to its cycles which are also
crazy (I open Pharo in headless, then the Pharo code opens a SDL2 window
and draws on it using Cairo). Then I was just careful on the number of
allocations, especially closures, in between frame rendering and also on
algorithms (I had 60% of time spent creating rectangle in corner: since it
performs a lot of min max computation, rewriting that to fastCorner method
without min max greatly improved the performance in my case). I still have
frame drops from time to time but that's hardly noticeable.

If you're scared of using Cairo / SDL2 because you deploy on specific
platforms like mobiles, you can still use BitBlt. The point being not to
run WorldMorph cycles at all but instead manage yourself what is drawn. If
possible don't use Morph at all too, it has many features that likely you
don't use, slowing down your system and wasting battery on mobiles for
nothing.

[1] https://github.com/clementbera/wizard-battle-arena
[2] https://github.com/clementbera/SpiderInvasion


On Wed, Apr 4, 2018, 15:49 Hilaire <hila...@drgeo.eu> wrote:

> Hi,
>
> I discover this Dr. Geo Smalltalk sketch to animate is about 60% slowler
> on P7 compare to P3:
>
> | fig point comment x y random inArc tries|
> "Monte-Carlo PI approximation"
> fig := DrGeoCanvas new fullscreen scale: 400.
> fig arcCenter: 0@0 from:  1@0 to: 0@1.
> fig polygon: { 0@0. 0@1. 1@1. 1@0 }.
> comment := fig texte: '' a: 0@ -0.1.
> random := Random seed: Time millisecondClockValue.
> tries := 500.
> inArc := 0.
> [1 a: tries faire: [: try |
>      x := random next.
>      y := random next.
>      point := (fig point: x@y) small.
>      (x squared + y squared) > 1
>          ifTrue: [point color: Color blue  ]
>          ifFalse: [inArc := inArc + 1 ].
> comment text: 'Tries: ', try asString, '
> approx: ', (inArc * 4 / try) asFloat asString.
> World doOneCycle.
> ] ] timeProfile
>
> The log are enclosed to compare. The mains differences seems to be
> during the world update. Years ago when porting to P3 I also see an
> important time performance degradation[1] and it remained unresolved.
>
>
> [1] http://forum.world.st/Slowness-question-tt4761717.html
>
>
>
>
> --
> Dr. Geo
> http://drgeo.eu
>
>

Reply via email to