Hi Toro's Sieve test

BlitzMax Forums/BlitzMax Programming/Hi Toro's Sieve test

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Tested the sieve code on PureBasic.
Check the results (in milliseconds):
Interations     PureBasic     BMaxBeta
      10000     2243 m/sec     953 m/sec
      15000     3354 m/sec    1899 m/sec
      20000     4547 m/sec    3767 m/sec

Go MAX!

NB: Using globals in max makes the results slower than pb.

PB Source:
; Ported from another Basic For benchmarking purposes...
; PureBasic version

OpenConsole()

#ITERATIONS=20000

Dim Flags(8191)
Print("SIEVE OF ERATOSTHENES - "+Str(#ITERATIONS)+" iterations")
ConsoleLocate(0,2)

t=GetTickCount_()

For Iter = 1 To #ITERATIONS

  Count = 0

  For I = 0 To 8190
    Flags(I) = 1
  Next

  For I = 0 To 8190
    If Flags(I)=1
       Prime = I + I
       Prime = Prime + 3
       K = I + Prime
       While K <= 8190
         Flags(K) = 0
         K = K + Prime
       Wend
       Count = Count + 1
    EndIf
  Next

Next

t=GetTickCount_()-t
Print(Str(#ITERATIONS)+" iterations took "+Str(t)+" m/secs.")
ConsoleLocate(0,3)
Print("Primes: "+Str(Count))

Delay(3000)
End