[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Speed differences fast and not fast


some is down to initialization i guess
it changes if you swap the methods over so quickly runs first, then slowly?
slowly is a bit quicker and quickly is a bit slower (but not a huge amount)

something seems Unsafe about it all though , can't quite put my finger on
the reason ;)

but i guess in all seriousness, is it "unsafe"? and why is it unsafe?

Respects
BruceS

On Wed, 8 May 2024 at 18:40, Brian G <brian@xxxxxxxxxxxxxxxx> wrote:

> I am surprised at the difference in a simple for loop between fast and
> not fast
>
> sample program follows and speeds printed after
>
> ' Gambas module file
>
> Public Sub Main()
>
>    Print "Hello world"
>    slowly()
>    quickly()
>
> End
>
> Public Sub slowly()
>    Dim startt As Float = CFloat(Now)
>    For i As Integer = 0 To 100000000
>      If i % 50000000 = 0 Then Print i
>    Next
>    Print "slowly : "; (CFloat(Now) - startt) * 100000.00
> End
>
> Fast Unsafe Public Sub quickly()
>    Dim startt As Float = CFloat(Now)
>    For i As Integer = 0 To 100000000
>      If i % 50000000 = 0 Then Print i
>    Next
>    Print "quickly : "; (CFloat(Now) - startt) * 100000.00
> End
>
> outputs the  following
>
> Hello world
> 0
> 50000000
> 100000000
> slowly : 13.7094873934984
> 0
> 50000000
> 100000000
> quickly : 0.175926834344864
>
> the difference is a lot larger than I thought  it was in the past.
>
> Am I doing something wrong here?
>
>
>
>

Follow-Ups:
Re: Speed differences fast and not fastJussi Lahtinen <jussi.lahtinen@xxxxxxxxx>
References:
Speed differences fast and not fastBrian G <brian@xxxxxxxxxxxxxxxx>