Page 1 of 2

Posted: Sun Nov 24, 2002 12:44 pm
by BackupUser
Restored from previous forum. Originally posted by lordperrin.

Hi all!

Once again I never did my homework.

It seems that Purebasic uses a highly optimized compiler. In fact it optimizes the code to the extent that the program posted here on the board never runs the loop with 100000 iterations at all.

for x=1 to 100000
y=y+1
next x

will be compiled as just x=100000

if you put print "hello" in the loop instead the outcome of the speed test is a very different one. With 1000 iterations I found this:

IBasic produces an exe with the size of 389(!) kb and runs in 631 ms.
PureBasic produces an exe with the size of 8 kb and runs in 1893(!) ms

So I guess when it comes to size PB rules. When it comes to speed, well it all depends on the program.

I am sure that there is space enough for both programs. I keep on using both. I like small executables! :)

Regards,

Lord Perrin

Posted: Sun Nov 24, 2002 1:11 pm
by BackupUser
Restored from previous forum. Originally posted by TheBeck.

> for x=1 to 100000
> y=y+1
> next x
>
> will be compiled as just x=100000

I don't think this is true. If you make the for next loop different sizes, you get different times.


> IBasic produces an exe with the size of 389(!) kb and runs in 631 ms.
> PureBasic produces an exe with the size of 8 kb and runs in 1893(!) ms

Yeah, it looks like PureBasic is slow writing to the console. I got 47464 ms for PureBasic and 5878 ms for IBasic. So it looks like the score now is PureBasic 1, IBasic 1. It would be interesting to see some real benchmarks for PureBasic and IBasic instead of these superficial ones, like math and string manipulation. Maybe I will whip something up tomorrow, but right now I got to get some sleep. L8R

Nathan Beckstrand - Calling from the great Pacific Northwest -=USA=-

Posted: Sun Nov 24, 2002 1:11 pm
by BackupUser
Restored from previous forum. Originally posted by tinman.
Originally posted by lordperrin
It seems that Purebasic uses a highly optimized compiler. In fact it optimizes the code to the extent that the program posted here on the board never runs the loop with 100000 iterations at all.

for x=1 to 100000
y=y+1
next x

will be compiled as just x=100000
I really doubt that, unless it compiles to "x=100000 : y=100000". Attached is some code that takes 0.77 seconds to run on my Duron 750. If it were to compile to "x=100000" then there is no way it would take that long (and it takes different times if you change the loop counter, so that shows your theory to be completely wrong).

Code: Select all

StartTime.l=StartProcessTimer_()for x.l=1 to 100000000
    y.l=y+1
next x
Elapsed$=GetProcessTime$(StartTime)
MessageRequester("Bench result", "Took "+Elapsed$+" and y="+Str(y)+" loops", #PB_MessageRequester_OK)
End
if you put print "hello" in the loop instead the outcome of the speed test is a very different one. With 1000 iterations I found this:

IBasic produces an exe with the size of 389(!) kb and runs in 631 ms.
PureBasic produces an exe with the size of 8 kb and runs in 1893(!) ms

So I guess when it comes to size PB rules. When it comes to speed, well it all depends on the program.
It also depends on some other things. You did remember to turn off the PB debugger when you ran it? Did you time the entire program or did you time the inner loop? Was your PB program outputting to the console (like my code below) which is quite slow (compared to e.g. writing to a file and even worse if you are moving the mouse while the console is active)?

The code here takes 5.28 seconds to run on my Duron750.

Code: Select all

If OpenConsole()

    StartTime.l=StartProcessTimer_()

    for x.l=1 to 1000
        y=y+1
        PrintN("hello")
    next x
    
    Elapsed$=GetProcessTime$(StartTime)
    MessageRequester("Bench result", "Took "+Elapsed$, #PB_MessageRequester_OK)

    CloseConsole()
EndIf
End
Update: Well I won't even bother timing either tests in IBasic because the first one (with y=y+1 in the loop) is a lot slower than PB. However, the one that prints hello is visibly faster in IBasic.

--
It's not minimalist - I'm increasing efficiency by reducing input effort.
(Win98first ed. + SP1, PB3.40)

Posted: Sun Nov 24, 2002 1:20 pm
by BackupUser
Restored from previous forum. Originally posted by fred.
Originally posted by lordperrin
It seems that Purebasic uses a highly optimized compiler. In fact it optimizes the code to the extent that the program posted here on the board never runs the loop with 100000 iterations at all.

for x=1 to 100000
y=y+1
next x

will be compiled as just x=100000
Why do you say something like that ? And you are affirmative with it, no doubt for you than it's compiled as a single line. Then just take a look to the generated asm. What you say is absolutely not true. We were talking to compiler quality, (ie: generated code), which has nothing to do with external commands like console one...

Fred - AlphaSND

Posted: Sun Nov 24, 2002 1:45 pm
by BackupUser
Restored from previous forum. Originally posted by lordperrin.

Fred is right and I am wrong. I will never say something like that again. Promise.

The fact is that purebasic is slow writing to the console but it's faster than light doing loops.

I have been utterly stupid. Please all forgive me. I will try to become a decent member of this community.

Yours,

LP

The generated code is as follows:
It is obvious for any one that the loop is indeed executed.

; For x=0 To 10000000
MOV dword [v_x],0
_For1
MOV eax,10000000
CMP eax,dword [v_x]
JL NEAR _Next2
; y=y+1
MOV ebx,dword [v_y]
INC ebx
MOV dword [v_y],ebx
; Next x
ADD dword [v_x],1
JMP NEAR _For1
_Next2

Posted: Sun Nov 24, 2002 1:57 pm
by BackupUser
Restored from previous forum. Originally posted by fred.

Ok, sorry for my worse comment but I was a bit upset to read something like that. Now better focus on coding something useful :).

Fred - AlphaSND

Posted: Sun Nov 24, 2002 2:03 pm
by BackupUser
Restored from previous forum. Originally posted by lordperrin.

Hi!

Trusting nobody I even disassembled the generated executable.

:004012E9 B880969800 mov eax, 00989680
:004012EE 3B051C224000 cmp eax, dword ptr [0040221C]
:004012F4 0F8C1C000000 jl 00401316
:004012FA 8B1D20224000 mov ebx, dword ptr [00402220]
:00401300 43 inc ebx
:00401301 891D20224000 mov dword ptr [00402220], ebx
:00401307 81051C22400001000000 add dword ptr [0040221C], 00000001
:00401311 E9D3FFFFFF jmp 004012E9

There is no doubt about it, a loop iterated 10.000.000 times. I will not give the name of the person who tricked me to believe otherwise. Let me just say that he's marketing, uh, well another programming language. And not in a very fair way at that.

Again,

Sorry all for being such a jerk.

/LP

Posted: Tue Nov 26, 2002 2:11 am
by BackupUser
Restored from previous forum. Originally posted by Jan.

I wrote a little speed test for 2D graphics (which are - in my opinion - more useful for speed tests than console PRINT) which compares PureBasic, DarkBasic, DarkBasic Pro, Visual Basic 6 and QuickBasic (with an ASM lib). If someone converts the code to IBasic I´ll be happy to add it to the list. Here´s the download link:

http://www.purebasic.de/files/speed.exe

It proves that PureBasic is by far the fastest :)

-Jan
My e-mail is [url]mailto:jbeuck@master-creating.com[/url]

Posted: Tue Nov 26, 2002 12:48 pm
by BackupUser
Restored from previous forum. Originally posted by Kale.

OMG! PB is FAST! :)

DB v1.13 = 2 screens full of grass
DBPro v1.03 = 526 screens full of grass
PureBasic v3.40 = 5516 screens full of grass!!!!!!

*stunned*

--Kale

New to PureBasic and falling in Love! :)

Posted: Mon Dec 02, 2002 3:35 pm
by BackupUser
Restored from previous forum. Originally posted by Syntax Error.

@Jan,

Could you please add BlitzBasic Test.exe to your zip.
From my tests PB & Blitz are very close.


My results:
DarkBasic v1.13 = ? .. (no figure shown)
Visual Basic = 1866
PureBasic v3.40 = 1962
BlitzBasic v1.79 = 2001

You can download source+exe from

http://homepage.ntlworld.com/config/sha ... zspeed.zip

Thanks

Posted: Mon Dec 02, 2002 7:02 pm
by BackupUser
Restored from previous forum. Originally posted by Kale.

YIKES! that blitz .exe size is 1.03Mb! but the source is only 372bytes?

--Kale

New to PureBasic and falling in Love! :)

Posted: Tue Dec 03, 2002 12:45 am
by BackupUser
Restored from previous forum. Originally posted by pusztry.

@Kale
I bet that the bitmap in a resource in the file its self. If not that is a HUGE file size. I can't even get it to run on my windows XP machine.

@Syntax Error
It gives me the error 'MEMORY ACCESS VIOLATION'

- Ryan


WinXP, PIII 800 MHz, 512MB RAM, SB Live 5.1, NVidia TNT 2 Ultra

Posted: Tue Dec 03, 2002 7:59 am
by BackupUser
Restored from previous forum. Originally posted by Syntax Error.

@pusztry,
The error is caused by the fact that the .exe is looking for

Ebene0.bmp

This is the same bitmap supplied in Jans Speed test program.
I have now included it in the zip in case you do not already have it.
Just make sure the bitmap is in the same location as Blitz Speed test.

@Kale,
Currenty, BlitzBasic includes all its 2d/3d libs in the exe.
The language itself is mainly designed as a games programming tool.

Could others give the Blitz Speed test a whirl an post your results.
I would be interested in seeing a general speed comparison.

Thanks..

Posted: Tue Dec 03, 2002 2:22 pm
by BackupUser
Restored from previous forum. Originally posted by Jan.

I made several speed tests with both langauges before we started our current project. The result is, that 2D speed is the same because the bottleneck DirectX eats up all significant differences. However, Blitz Basic is slower for 2D games as nearly EVERY command in PureBasic is much faster. Loops like FOR/NEXT are, depending on the hardware, 10 to 100(!) times faster.

This means: For a small game it makes nearly no difference, but when it comes to more or less complex calculations PureBasic is much faster. The reason for this is that Blitz Basic is nearly entirely written in C++.

Posted: Wed Dec 04, 2002 4:37 am
by BackupUser
Restored from previous forum. Originally posted by pusztry.

@Syntax Error
That fixes it thanks

- Ryan


WinXP, PIII 800 MHz, 512MB RAM, SB Live 5.1, NVidia TNT 2 Ultra