PDA

View Full Version : Need confirmation on thinCore speed



ErosOlmi
11-10-2007, 16:48
Hi all,

I think I've got some more speed improvements in thinBasic Core, enough significant to ask you for some tests.
If you have some spare time, can you please download attached thinCore.dll file (copy over the one you will find into \thinBasic\ directory) and make some speed tests using the scripts you will find into \thinBasic\SampleScripts\General\Speed\ directory?

Improvements should be all over the script execution and not specific to some particular situation. Mainly I've changed the way LONG numbers are handled inside Core engine. Previously I was using POKE/PEEK while this core has pointers to LONGs instead. If you will confirm the same improvement I've got (about 5/10%) I will change all other numeric types.

Thanks a lot
Eros

matthew
11-10-2007, 17:43
I ran Four tests, most of them are faster with the new dll. :)

If I had remembered to turn my Web browser off during the tests they probably all would be faster, lol. :D

The first Four images are BEFORE I changed the dll and last Four are AFTER.

ErosOlmi
11-10-2007, 17:47
Thanks a lot matthew.

Hey the first test, the one with 100000 different loop type seem very significant! Maybe too much.
Was the first script executed after some thinBasic run or was it executed as first thinBasic script during the day? It may suffer from some caching.

Ciao
Eros

Michael Clease
11-10-2007, 17:49
Here are my results with modified test routines.

have fun.

ErosOlmi
11-10-2007, 17:55
Abraxas, no improvements but worst results in your case.
What a success I've got!

A little note: in you script USES "CORE" is not needed because loaded by default.

matthew
11-10-2007, 17:56
...Was the first script executed after some thinBasic run or was it executed as first thinBasic script during the day? It may suffer from some caching...


Before I ran the tests I downloaded the new preview version of ThinBASIC.

It was the first script I ran after installation.

Michael Clease
11-10-2007, 17:59
Eros didnt think I needed it, thanks.

Can a script call another script?

ErosOlmi
11-10-2007, 18:05
You can call another script by shelling a new process like any other shell command.
With thinBasic scripts you cannot make something like "chaining".

But this is an interesting idea ::)

GSAC3
11-10-2007, 18:16
Eros:

Attached are some spped test for you.

Don B.

Petr Schreiber
11-10-2007, 18:43
Hi Eros,

seems nice here, about 10-20% speed increase in loops !
Just one thing - is it safe to use LONG instead of DWORD for pointers ?

No GPF or anything, just curious :)


Thanks a lot,
Petr

ErosOlmi
11-10-2007, 19:48
To me, every time a DWORD is expected as BYVAL, it is safe to use LONG.
So far (many years :D) I never had any kind of problems.

Anyway changes I just made in thinCore engine are not mixing LONG and DWORD but substituting the way I used to get and store values in numeric variables. So mainly changing from something like

Poke Long, pDataStorage, lItemValue
with

p_LONG = pDataStorage
@p_Long = lItemValue
where pDataStorage is a generic DWORD (it point where the real variable data is stored) and p_LONG is a LONG PTR

So it is much faster to use pointers to memory data than using POKE/PEEK.

On my system I've got very significant improve. For me 10% is very significant. And consider I just change few places where my old technique was used so I expect much more improvements.

Another important aspect about new technique is a more simple way to handle UDT elements, in fact I was working on recursive UDT (you know, my current beast) when discovered this kind of optimizations.

Ciao
Eros

Michael Hartlef
11-10-2007, 20:10
Here are the results from the german jury: ITALY.... 10 points ;D

kryton9
11-10-2007, 20:58
I modified the test scripts to save the results to a text file.

It will automatically create a file named: test results.csv
As you run each test it will append the time data to the file in the following way:
Test Name, time

Once all the tests are run. Rename your test results.csv to old test results.csv

Then once you update thinCore, run the tests again and you will end up with another test results.csv
Rename this to new test results.csv

Then you can import this data into a spreadsheet.
What I do is import old test result.csv
I add a column to the data and fill it with "old"

Then I import the new test results and fills its column with "new"

Then sort the data by testname, old/new

All the scripts with slight changes are attached.

here are my results:

Speed Test Loops: DO UNTIL 531 new
Speed Test Loops: DO UNTIL 531 old 0.00%
Speed Test Loops: DO WHILE 141 new
Speed Test Loops: DO WHILE 141 old 0.00%
Speed Test Loops: FOR 109 new
Speed Test Loops: FOR 109 old 0.00%
Speed Test Loops: TOTAL 813 new
Speed Test Loops: TOTAL 1407 old 42.22%
Speed Test Loops: WHILE 125 new
Speed Test Loops: WHILE 141 old 11.35%
Speed2 Function MultiParams vs SingleUDT 3 params BYREF 1.14 new
Speed2 Function MultiParams vs SingleUDT 3 params BYREF 1.078 old -5.75%
Speed2 Function MultiParams vs SingleUDT 3 params BYVAL 1.14 new
Speed2 Function MultiParams vs SingleUDT 3 params BYVAL 1.093 old -4.30%
Speed2 Function MultiParams vs SingleUDT function no params 0.25 new
Speed2 Function MultiParams vs SingleUDT function no params 0.25 old 0.00%
Speed2 Function MultiParams vs SingleUDT UDT with 3 elements 0.703 new
Speed2 Function MultiParams vs SingleUDT UDT with 3 elements 0.657 old -7.00%
Speed2 Function With Params 0.734 new
Speed2 Function With Params 0.718 old -2.23%
Test Speed 2 172 new
Test Speed 2 188 old 8.51%
Test Speed 2 Function 0.218 new
Test Speed 2 Function 0.234 old 6.84%
Test Speed 2 Function with Locals 0.844 new
Test Speed 2 Function with Locals 0.813 old -3.81%
Test Speed 2 Typed 250 new
Test Speed 2 Typed 250 old 0.00%
Test Speed Count One Million 0.297 new
Test Speed Count One Million 0.312 old 4.81%
Test Speed CountOneMillion No Function 0.297 new
Test Speed CountOneMillion No Function 0.312 old 4.81%
Test Speed One Million SIN COS 1.156 new
Test Speed One Million SIN COS 1.188 old 2.69%

Petr Schreiber
11-10-2007, 22:18
Mike,

please stop having same numbers as I get :D

Kent your idea is great, what about total elimination of MSGBOX + BAT file to play all scripts in sequence :) ?


Petr

kryton9
11-10-2007, 23:01
Cool Petr, nice thinking!

While driving this afternoon after the first post, I was thinking, is this where we could use Eros' vbscripting tools to output the data to a spreadsheet directly, then do the sorts and calculations?

Michael Clease
11-10-2007, 23:46
I made this earlier but had to got out and it looks like me and Petr had the same idea.

Randall
12-10-2007, 03:48
I made a quick test...

CPU: AMD Athlon X2 Dual Core 3600+ (1.9gHz)
Memory: 2GB
OS: Windows 2000 SP4
thinBasic: 1.4.0.1




Old New Delta % Change
Test_Speed 100,000 FOR 141 141 0 0.00% Unchanged
100,000 WHILE 12,000 12,453 453 3.76% Slower
100,000 DO WHILE 9,000 12,484 3,484 38.71% Slower
100,000 DO UNTIL 11,828 14,141 2,313 19.56% Slower
Total 32,969 39,219 6,250 18.96% Slower
Test_Speed_CountOneMillion 0.390000 0.375000 0.015 3.85% Faster
Test_Speed_CountOneMillion_NotFunction 0.390000 0.344000 0.046 11.80% Faster
Test_Speed_OneMillion_SIN_COS 1.485000 1.422000 0.063 4.24% Faster
Test_Speed2 218 219 1 0.46% Slower
Test_Speed2_Function 0.282000 0.281000 0.001 0.36% Faster
Test_Speed2_Function_MultiParamsVsSingleUDT 3 params passed BYVAL 1.250000 1.328000 0.078 6.24% Slower
3 params passed BYREF 1.203000 1.282000 0.079 6.57% Slower
UDT containing 3 elements 0.719000 0.797000 0.078 10.85% Slower
Without any parameters 0.312000 0.297000 0.015 4.81% Faster
TestSpeed2_Function_WithLocals 0.937000 0.985000 0.048 5.12% Slower
Test_Speed_Function_WithParams 0.813000 0.859000 0.046 5.66% Slower
Test_Speed2_Typed 281 312 31 11.03% Slower

Petr Schreiber
12-10-2007, 09:25
Abraxas,

good your one minute warning turned to few seconds :)

Kent - did you looked at BIFF module ? It allows to write XLS file.
Sadly not formulas, but still very good.

Randall - excellent table ! Do you use GetTickCount or QueryPerformanceTimer ?


Petr

EDIT: Corrected name, I am becoming old and crosseyed :D

ErosOlmi
12-10-2007, 10:36
Ok, thanks to all for the excellent work!

Not worth to go on because I need to reconsider some internal spects. My new method do not consider possible future multithreading because it uses some global variables. So I need to find another way to store dummy pointers other than global scope.

Thanks again
Eros