Results 1 to 7 of 7

Thread: Equation solved 100000 times

  1. #1
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,795
    Rep Power
    10

    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
    DIM T1 AS quad
    DIM T2 AS quad

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

    '---Here we go ...
    '---Ask if ...
    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
    result = (((n_str*85+n_lvl)*n_wp)-((n_vit*90+n_adef)*n_lvl))/2
    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
    function = (((n_str*85+n_lvl)*n_wp)-((n_vit*90+n_adef)*n_lvl))/2
    end function

    [/code]
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  2. #2
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Naples, Florida & Duluth, Georgia
    Age
    68
    Posts
    3,869
    Rep Power
    404

    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.
    Acer Notebook: Win 10 Home 64 Bit, Core i7-4702MQ @ 2.2Ghz, 12 GB RAM, nVidia GTX 760M and Intel HD 4600
    Raspberry Pi 3: Raspbian OS use for Home Samba Server and Test HTTP Server

  3. #3

    Re: Equation solved 100000 times

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

    1st - 281 msecs
    2nd - 375 msecs
    Operating System: Windows 10 Home 64-bit
    CPU: Intel Celeron N4000 CPU @ 1.10GHz
    Memory: 4.00GB RAM
    Graphics: Intel UHD Graphics 600

  4. #4
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,138
    Rep Power
    733

    Re: Equation solved 100000 times

    Ouch ,

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


    Bye,
    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  5. #5
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Naples, Florida & Duluth, Georgia
    Age
    68
    Posts
    3,869
    Rep Power
    404

    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.
    Acer Notebook: Win 10 Home 64 Bit, Core i7-4702MQ @ 2.2Ghz, 12 GB RAM, nVidia GTX 760M and Intel HD 4600
    Raspberry Pi 3: Raspbian OS use for Home Samba Server and Test HTTP Server

  6. #6
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,795
    Rep Power
    10

    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
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  7. #7
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Naples, Florida & Duluth, Georgia
    Age
    68
    Posts
    3,869
    Rep Power
    404

    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.
    Acer Notebook: Win 10 Home 64 Bit, Core i7-4702MQ @ 2.2Ghz, 12 GB RAM, nVidia GTX 760M and Intel HD 4600
    Raspberry Pi 3: Raspbian OS use for Home Samba Server and Test HTTP Server

Similar Threads

  1. Problems / thinAir / Tabs [ maybe solved already ]
    By Petr Schreiber in forum Preview testing
    Replies: 7
    Last Post: 23-10-2008, 15:34

Members who have read this thread: 0

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
  •