# Thread: Equation solved 100000 times

1. ## Equation solved 100000 times

A classical FOR/NEXT loop to show speed execution.
Under a Centrino Duo 2Ghz this script is executed in 200 milliseconds.
100000 iterations.

[code=thinbasic]
'---
' Sample script to demonstrate how fast thinBasic is
' The below function is resolved MaxCount times
'---

'---Some predefined values
DIM n_str AS EXT VALUE 100
DIM n_lvl AS EXT VALUE 100
DIM n_wp AS EXT VALUE 100
DIM n_vit AS EXT VALUE 100
DIM n_adef AS EXT VALUE 100
DIM MaxCount AS LONG value 100000

'--Results and counters
DIM result AS EXT
DIM counter AS LONG

'---For time measuring

'---Used for string output
DIM Message AS STRING

'---Here we go ...
Message = "This program will solve a simple math expression " & MaxCount & " times.\n"
Message += "Please press Yes to go on, NO to Stop\n"
DIM lResult AS LONG = MSGBOX(0, Message, %MB_YESNO, "Continue?")
IF lResult <> %IDYES THEN
STOP
END IF

'---Get initial time
T1 = gettickcount

'---Loops and get result
FOR counter = 1 TO MaxCount
NEXT

'---Get final time
T2 = gettickcount

'---Show results
MSGBOX 0, "mSecs:" & \$tab & FORMAT\$(T2 - T1, "#0") & \$CRLF & _
"Result:" & \$tab & result & \$crlf & _
""
[/code]

And here almost the same script but now calculation is performed by a specific function.
Execution times on a Centrino Duo 2GHz is about 590 milliseconds.

[code=thinbasic]
DIM n_str AS EXT VALUE 10000
DIM n_lvl AS EXT VALUE 10000
DIM n_wp AS EXT VALUE 10000
DIM n_vit AS EXT VALUE 10000
DIM n_adef AS EXT VALUE 10000
DIM Result AS EXT
DIM counter AS LONG
DIM MaxCount AS LONG = 100000

DIM T1 AS DOUBLE
DIM T2 AS DOUBLE

DIM Message AS STRING
Message = "This program will solve a simple math expression " & MaxCount & " times.\n"
Message += "Please press Yes to go on, NO to Stop\n"

DIM lResult AS LONG = MSGBOX(0, Message, %MB_YESNO, "Continue?")
IF lResult <> %IDYES THEN
STOP
END IF

T1 = TIMER
Result = 0
FOR counter = 1 TO MaxCount
result = CalcFormula
NEXT
T2 = TIMER

MSGBOX(0, _
"Seconds:" & \$tab & \$tab & FORMAT\$(T2 - T1, "#0.000000") & \$CRLF & _
"Result:" & \$tab & \$tab & result & \$crlf & _
"" _
)

'---
' Formula calculation
'---
function CalcFormula() as ext
end function

[/code]

2. ## Re: Equation solved 100000 times

The first test took 250 ms and the second test 328 ms. Amazing to think 100,000 of anything that quickly.

3. ## Re: Equation solved 100000 times

Here are the Results from my 1.40GHz Celeron Laptop...

1st - 281 msecs
2nd - 375 msecs

4. ## Re: Equation solved 100000 times

Ouch ,

my Duron 850 does it in 635 - 653 ( really ) ms

Bye,
Petr

5. ## Re: Equation solved 100000 times

Petr when you compare your Duron to my AMD X2 4600 with 2 gigs ram, the performance is much better compared to the speed of the chip. I am dissappointed by my AMD X2, I just don't see the speed I thought I would with it. This is not one I built either. I bought an HP so I know it is configured optimal, so the speed is just not there like I thought it would be.

I also saw a video tutorial on an AMD X2 on terragen 2 by another 3dBuzz member and the renders were very very slow too. Although the articles on Tom's Hardware made it sound like the X2's were faster than Intels Dual Cores, I think in real world applications the Dual Core Intels are much faster.

6. ## Re: Equation solved 100000 times

Ken,

I compared a lot of speed tests between Intel P4 3.2Gh HyperT (HP machines) and my laptop Centrino Core 2 2Gh.
Core 2 is unbeatable. All tests run almost at double speed and consider thinBasic has no multithread handling inside.

So, Intel made a lot work on optimization. When I see task manager I can see both Core are working so it means even if thinBasic is not multithread in some way processor is able to make parallel optimizations.

Ciao
Eros

7. ## Re: Equation solved 100000 times

Thanks Eros, I am thinking of making a new gaming machine in the future. I will ask at that time for input on cpu recommendations as I will do research also. The new intel's seem really great!! Glad you verified that with your tests too.

There are no members to list at the moment.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•