Floating Point Speed - Comparison of VB 5.0, Delphi 3.0, and VC 5.0
Author |
Message |
David Chie #1 / 12
|
 Floating Point Speed - Comparison of VB 5.0, Delphi 3.0, and VC 5.0
Moving up from fortran, I needed to determine which modern development language/platform generated the faster (fastest will vary according to application, code design, and useage) compiled floating point-intensive programs. Apparently, VB5.0 using the new, optimzing compiler is nowhere as good as Microsoft keeps saying it is -- just a 2x performance increase over VB5.0 P-code. However, delphi is suprising for it's great performance right out of the box! Almost as fast as VC 5.0, and probably an easier development environment to start with. Here's the figures: 1000x1000 array VC 5.0 Delphi 3.0 Lahey ELF90 VB 5.0 Optimzed VB 5.0 P-code 1st run:5(4) 5(4) 8(6) 13(10) 24(20) seconds 2nd run:4(3) 5(4) 8(6) 13(10) 24(19) 1500x1500 array VC 5.0 Delphi 3.0 Lahey ELF90 VB 5.0 Optimzed VB 5.0 P-code 1st run:9(8) 10(9) 17(13) 30(23) 60 seconds 2nd run:9(8) 9(9) 17(13) 29(22) 60 The first number of pairs of numbers is the time from when the program was told to start running the subroutine, until it finished (ie. total time including array setup time). The second number was the time actually spend in the array calculation loop itself (run time). Thus, subtracting (total time) - (run time) = (overhead time), in general. Either using program coded timers or stopwatch. The 1st run are times for the first time the program was launched and executed. The 2nd run is for the second time the program was asked to run it again right after the 1st run (taking into some account overhead due to setting up memory and program caching). Cyrix 6x86, 512KB cache, 32MB ram, 2.0GB EIDE, 1280x1024 Diamond Stealth 3000 3D 4MB, Windows 95, Ethernet networked, desktop image, a couple handy Windows TSRs loaded (eg. VSCAN), but generally nothing else running from a clean start. David =) Delphi 3.0 code------------- unit Unit1; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Math; type TForm1 = class(TForm) Start: TButton; MyMemo: TMemo; procedure StartClick(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.DFM} {$M 10000000,10000000} procedure TForm1.StartClick(Sender: TObject); var myArray : array [1..1000,1..1000] of double; StartTime, EndTime : TDateTime; k,j : integer; begin for k := 1 to 1000 do for j := 1 to 1000 do myArray[k,j] := Random * 1000; StartTime := Time; for k := 1 to 1000 do for j := 1 to 1000 do myArray[k,j] := myArray[j,k] * myArray[k,j] - myArray[j,1001-j] / myArray[k,1001-k] * Log2(Random) / (Random + myArray[1001 -j,k]); EndTime := Time; MyMemo.Lines.Add ('Start Time: ' + TimeToStr(StartTime) + ' End Time: ' + TimeToStr(endTime)); end; end. VC 5.0 code---------- #include <float.h> #include <iostream.h> #include <stdlib.h> #include <math.h> #include <time.h> #include <stdio.h> double myArray[1500][1500]; void main( int argc, char *argv[] ) { char tmpbuf[128]; _tzset(); _strtime( tmpbuf ); printf( "begin here - OS time:\t\t\t\t%s\n", tmpbuf ); srand( (unsigned)time( NULL ) ); int k,j; for (k = 0; k < 1501; k++) for (j = 0; j < 1501; j++) myArray [k][j] = rand() * 1000; _strtime( tmpbuf ); printf( "start OS time:\t\t\t\t%s\n", tmpbuf ); for (k = 0; k < 1501; k++) for (j = 0; j < 1501; j++) myArray[k][j] = myArray[j][k] * myArray[k][j] - myArray[j][1501-j] / myArray[k][1501-k] * log(rand()) / (rand() + myArray[1501-j][k]); _strtime( tmpbuf ); printf( "end OS time:\t\t\t\t%s\n", tmpbuf ); Quote: }
Fortran code ------------- ! ~ 5 seconds using Lahey's free EL-F90 DOS compiler ! - This compiler does not make optimizations! program Test implicit none real :: MyArray(1000,1000) integer :: k,j real :: rnd, rnd2 do k = 1,1000 do j = 1,1000 call RANDOM_NUMBER ( Harvest = rnd) myArray(k,j) = rnd * 1000 end do end do write (*,*) " Starting " do k = 1,1000 do j = 1,1000 call RANDOM_NUMBER ( Harvest = rnd ) call RANDOM_NUMBER ( Harvest = rnd2 ) myArray(k,j)=myArray(j,k)*myArray(k,j)-myArray(j,1001-j) / myArray(k,1001-k)*Log(rnd) / (rnd2 + myArray(1001-j,k)) end do end do write (*,*) " Stopping " stop end program Test Basic code-------- Private Sub StartButton_Click() dim myArray(1000,1000) as double dim StartTime dim EndTime Dim k,j as integer for k = 1 to 1000 for j = 1 to 1000 myArray(k,j) = rnd*1000 next j next k starttime = time for k = 1 to 1000 for j = 1 to 1000 myArray(k,j) = myArray(j,k) * myArray(k,j) - myArray(j,1001-j)/MyArray(k,1001-k) * log(rnd)/(rnd + myArray(1001-j,k) next j next k EndTime = time MyTextBox.Text = "Start Time: " + str(StartTime) + " End Time: " + str(EndTime) End Sub ----------------------------------------------------------
|
Tue, 28 Dec 1999 03:00:00 GMT |
|
 |
Alan Dav #2 / 12
|
 Floating Point Speed - Comparison of VB 5.0, Delphi 3.0, and VC 5.0
Hello, Speed is only one option to take into account when selecting a development tool, but as this thread is about speed, I though I would mention this - I wrote a program in Delphi 2.0 which included populated a ListView control, very simple, nothing fancy. I ported the code to vb 4, the code took just under half the time to run! I like borlands Delphi, and in your case you are right to choose, it. Thanks for the insight, David. Alan Davis, Southampton, England
|
Wed, 29 Dec 1999 03:00:00 GMT |
|
 |
Stefan Hoffmeist #3 / 12
|
 Floating Point Speed - Comparison of VB 5.0, Delphi 3.0, and VC 5.0
Quote: >Hello, >Speed is only one option to take into account when selecting a >development tool, but as this thread is about speed, I though I would >mention this - >I wrote a program in Delphi 2.0 which included populated a ListView >control, very simple, nothing fancy. I ported the code to vb 4, the >code took just under half the time to run!
There have been mentioned a couple of ways to speed up the Delphi listview by some orders of magnitude, using simple, built-in techniques. --
http://kakadu.rz.uni-passau.de/~w4hoff01/
|
Wed, 29 Dec 1999 03:00:00 GMT |
|
 |
nospam.co #4 / 12
|
 Floating Point Speed - Comparison of VB 5.0, Delphi 3.0, and VC 5.0
Quote: > Moving up from Fortran, I needed to determine which modern development > language/platform generated the faster (fastest will vary according to > application, code design, and useage) compiled floating point-intensive > programs. > Apparently, VB5.0 using the new, optimzing compiler is nowhere as good > as Microsoft keeps saying it is -- just a 2x performance increase over > VB5.0 P-code. > However, Delphi is suprising for it's great performance right out of > the box! Almost as fast as VC 5.0, and probably an easier development > environment to start with. > Here's the figures: > 1000x1000 array > VC 5.0 Delphi 3.0 Lahey ELF90 VB 5.0 Optimzed VB 5.0 P-code > 1st run:5(4) 5(4) 8(6) 13(10) 24(20) seconds
[skip] Quote: > Delphi 3.0 code------------- ....... > StartTime := Time; > for k := 1 to 1000 do > for j := 1 to 1000 do > myArray[k,j] := myArray[j,k] * myArray[k,j] - myArray[j,1001-j] > / myArray[k,1001-k] * Log2(Random) / (Random + myArray[1001 -j,k]); > EndTime := Time;
David, though it's a pleasure to hear that Delphi outruns Lahey FORTRAN, I'm afraid that what you actually have measured is the performance of random... That can be interesting on its own rights, but Delphi's built-in random is too poor to be used for real calculations (old multiplicative stuff inside). If you want real comparison I would advise you to run the Whetstone test. If you need the source, drop me an Email. Also I don't think that the speed should be the only consideration when choosing the language. Delphi provides best-on-the-market environment, but I would consider several other issues before porting a FORTRAN program into a new language. For example, if you have a lot of subroutines taking 2D arrays and their dimensions as arguments it's going to be a real pain to convert them into Pascal. Conversion to C is much easier (and you can use fort2c to do much of the job). If you don't want to give up the user-friendly environment of Delphi, consider Borland's C++ builder: it's Delphi-2 sister-product with the only difference that it employs C++ instead of Pascal. Good luck, -- Eugene I Levin Bielefeld, Germany I'm sorry for coding my Email in the header. Here is the right one:
|
Thu, 30 Dec 1999 03:00:00 GMT |
|
 |
iliadis ili #5 / 12
|
 Floating Point Speed - Comparison of VB 5.0, Delphi 3.0, and VC 5.0
Since you use the RNDfunction inside code timed it is difficult to say which language is faster since every language uses internal functions for RND (which in no case are subject for checking fastness of compiled program) Quote:
>Moving up from Fortran, I needed to determine which modern development >language/platform generated the faster (fastest will vary according to >application, code design, and useage) compiled floating point-intensive >programs. >Basic code-------- >starttime = time >for k = 1 to 1000 >for j = 1 to 1000 > myArray(k,j) = myArray(j,k) * myArray(k,j) - >myArray(j,1001-j)/MyArray(k,1001-k) * log(rnd)/(rnd + myArray(1001-j,k)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Quote: >next j >next k >EndTime = time
|
Fri, 31 Dec 1999 03:00:00 GMT |
|
 |
David Chie #6 / 12
|
 Floating Point Speed - Comparison of VB 5.0, Delphi 3.0, and VC 5.0
Quote:
> Interestingly enough, I got the same (Delphi) score with my Intel P5-133, > which leads me to belive that you're probably running on an external bus > speed of 66MHz with EDO RAM just like me? Accessing an 8MB large array > probably puts the bottleneck on the memory bus speed...
Actually, the Cyrix floating point processor is significantly slower than that in the AMD or Pentium processors. So, a Cyrix 166+ is more like a P90-P120. (some motherboards Quote: > allow overclocking to 83MHz, check out http://sysdoc.pair.com for details)
Seen that. But, the trouble is that the Cyrix chips really can't be overclocked that much above their ratings. I'm working with a vendor now that can't even get a Cyrix 200+ running at 200mhz, only 166mhz, due to thermal problems or whatever.
|
Fri, 31 Dec 1999 03:00:00 GMT |
|
 |
David Chie #7 / 12
|
 Floating Point Speed - Comparison of VB 5.0, Delphi 3.0, and VC 5.0
Quote: > > Delphi 3.0 code------------- > ....... > > StartTime := Time; > > for k := 1 to 1000 do > > for j := 1 to 1000 do > > myArray[k,j] := myArray[j,k] * myArray[k,j] - myArray[j,1001-j] > > / myArray[k,1001-k] * Log2(Random) / (Random + myArray[1001 -j,k]); > > EndTime := Time; > David, > though it's a pleasure to hear that Delphi outruns Lahey FORTRAN, I'm > afraid that what you actually have measured is the performance of > random... That can be interesting on its own rights, but Delphi's > built-in random is too poor to be used for real calculations (old > multiplicative stuff inside). If you want real comparison I would
I'm going on the belief that, by now, most manufacturers have optimized the basic functions (sin, cos, log, rnd) pretty good, and even if these functions can be further optimized, I wouldn't be the one to spend time rewriting such in my own programs. You can easily test the overhead of such by placing just the function calls into a big loop. Anyways, the close values for VC, Delphi and Fortran vs. VB suggests that more than a poorly written random function is the cause. Other publications have already tested these compliers themselves, so I'm apt to believe that these figures are pretty good in revealing the floating point speeds of each. Also, the Fortran was Lahey's free complier off their web page, a non-optimizing compiler. david =)
|
Fri, 31 Dec 1999 03:00:00 GMT |
|
 |
Rune Mobe #8 / 12
|
 Floating Point Speed - Comparison of VB 5.0, Delphi 3.0, and VC 5.0
Quote:
>1000x1000 array > VC 5.0 Delphi 3.0 Lahey ELF90 VB 5.0 Optimzed VB 5.0 P-code >1st run:5(4) 5(4) 8(6) 13(10) 24(20) seconds >Cyrix 6x86, 512KB cache, 32MB ram, 2.0GB EIDE, 1280x1024 Diamond
Interestingly enough, I got the same (Delphi) score with my Intel P5-133, which leads me to belive that you're probably running on an external bus speed of 66MHz with EDO RAM just like me? Accessing an 8MB large array probably puts the bottleneck on the memory bus speed... (some motherboards allow overclocking to 83MHz, check out http://sysdoc.pair.com for details) (I really look forward to 100MHz bus with 10ns SDRAM DIMMs) -- =\
|
Fri, 31 Dec 1999 03:00:00 GMT |
|
 |
nospam.co #9 / 12
|
 Floating Point Speed - Comparison of VB 5.0, Delphi 3.0, and VC 5.0
Quote:
>> though it's a pleasure to hear that Delphi outruns Lahey FORTRAN, I'm >> afraid that what you actually have measured is the performance of >> random... That can be interesting on its own rights, but Delphi's >> built-in random is too poor to be used for real calculations (old >> multiplicative stuff inside). > I'm going on the belief that, by now, most manufacturers have > optimized the basic functions (sin, cos, log, rnd) pretty good,
Well, as for sin(), cos(), log() and sqrt() I agree. These functions are supported by hardware, so there is no real room for manufacturer's creativity :-). With rnd() it's completely another story, since it's not a matter of code optimization, it's matter of its "brains". The basic difference lies in the nature of the functions: everybody knows what is sqrt(), while nobody can actually tell you what should rnd() compute. Delphi's random() has been carefully hand-coded in the assembler, but the multiplicative algorithm they use has been being severely criticized since 60-s... Quote: > Anyways, the close values for VC, Delphi and Fortran vs. VB suggests > that more than a poorly written random function is the cause.
Yes, sure. It's just not a matter to discuss in a Delphi newsgroup, since there are nobody who would object this statement :) Quote: > Also, the Fortran was Lahey's free complier off their web page, a > non-optimizing compiler.
This makes a difference. I hope Lahey people read this and the next time they will put on the web an optimizing compiler to avoid the bad publicity (well, just kidding ;-) ). Happy coding, -- Eugene I Levin Bielefeld, Germany I'm sorry for corrupting my Email in the header. Here is the right one:
|
Sat, 01 Jan 2000 03:00:00 GMT |
|
 |
Dave #10 / 12
|
 Floating Point Speed - Comparison of VB 5.0, Delphi 3.0, and VC 5.0
I did as Eugene suggested and ran the Whetstone with Delphi v3.0 and Powersofts Power++ (Watcom v11.0 C/C++ compiler) v2.0: Power++ p0() and p3() inlined: 144.3 MFLOPS (1.66x) not inlined: 113.0 MFLOPS (1.30x) Delphi v3.0: 86.7 MFLOPS (1.0x) Timed on a DELL XPS P200s - Intel P5/200 - Win95 - 32 MB RAM Default "fast code" opts. were used for both. Code was basically just "copied and pasted" from Power++ to Delphi and then some of the syntax and names of some of the math functions were changed to conform to Pascal and the Delphi math lib. One other thing to note is that the for loop counter var. was moved from the heap to the stack for both programs (so the code was compatible) because the Delphi compiler issued a warning on that. Hope this us useful to someone. Dave F. Quote: > David, > though it's a pleasure to hear that Delphi outruns Lahey FORTRAN, I'm > afraid that what you actually have measured is the performance of > random... That can be interesting on its own rights, but Delphi's > built-in random is too poor to be used for real calculations (old > multiplicative stuff inside). If you want real comparison I would advise > you to run the Whetstone test. If you need the source, drop me an Email.
|
Sat, 01 Jan 2000 03:00:00 GMT |
|
 |
Pascal Jasm #11 / 12
|
 Floating Point Speed - Comparison of VB 5.0, Delphi 3.0, and VC 5.0
Quote:
>1000x1000 array > VC 5.0 Delphi 3.0 Lahey ELF90 VB 5.0 Optimzed VB 5.0 P-code >1st run:5(4) 5(4) 8(6) 13(10) 24(20) seconds >2nd run:4(3) 5(4) 8(6) 13(10) 24(19) >1500x1500 array > VC 5.0 Delphi 3.0 Lahey ELF90 VB 5.0 Optimzed VB 5.0 P-code >1st run:9(8) 10(9) 17(13) 30(23) 60 seconds >2nd run:9(8) 9(9) 17(13) 29(22) 60 > The first number of pairs of numbers is the time from when the program >was told to start running the subroutine, until it finished (ie. total >time including array setup time). The second number was the time >actually spend in the array calculation loop itself (run time). Thus, >subtracting (total time) - (run time) = (overhead time), in general.
Just a few observations. I'm not claiming vb is faster than the other languages. 1. You're using integer array indexes. 1,000,000 int increments, and lookups. I believe a long index value would shave some siginificant time. It could help the other languages too, though. 2. You're relying heavily on the internal random number generator of each language. In addition to varying internal algorithms, that could for instance poduce longer non-repeating streams at the expense of speed, VB is penalized for calling a dll, instead of static linking. The other compilers may even be inlining the call. This heavy reliance is probably the biggest reason why compiled is comparatively underwhelming to p-code. I estimate 30%-50% of time is spent calling the Rnd() function.
|
Sat, 01 Jan 2000 03:00:00 GMT |
|
 |
Gene #12 / 12
|
 Floating Point Speed - Comparison of VB 5.0, Delphi 3.0, and VC 5.0
Check out the series of benchmarks in the May 1997 issue of Visual Basic Programmer's Journal comparing VB5 with VB3, VB4-16, VB4-32, Delphi 2, VC++4, VC++5, and VJ++ 1.1 Overall, Delphi 2 beats out VB5 or is very close to VB5. The only exception is with the OCX/ActiveX Form Load benchmark where VB5 is much better than Delphi 2. It will be interesting to see how these compare with Delphi 3. Gene Eugene I Levin -- remove "nospam.com" to reply!
Quote:
> > Moving up from Fortran, I needed to determine which modern development > > language/platform generated the faster (fastest will vary according to > > application, code design, and useage) compiled floating point-intensive > > programs. > > Apparently, VB5.0 using the new, optimzing compiler is nowhere as good > > as Microsoft keeps saying it is -- just a 2x performance increase over > > VB5.0 P-code. > > However, Delphi is suprising for it's great performance right out of > > the box! Almost as fast as VC 5.0, and probably an easier development > > environment to start with. > > Here's the figures: > > 1000x1000 array > > VC 5.0 Delphi 3.0 Lahey ELF90 VB 5.0 Optimzed VB 5.0 P-code > > 1st run:5(4) 5(4) 8(6) 13(10) 24(20) seconds > [skip] > > Delphi 3.0 code------------- > ....... > > StartTime := Time; > > for k := 1 to 1000 do > > for j := 1 to 1000 do > > myArray[k,j] := myArray[j,k] * myArray[k,j] - myArray[j,1001-j] > > / myArray[k,1001-k] * Log2(Random) / (Random + myArray[1001 -j,k]); > > EndTime := Time; > David, > though it's a pleasure to hear that Delphi outruns Lahey FORTRAN, I'm > afraid that what you actually have measured is the performance of > random... That can be interesting on its own rights, but Delphi's > built-in random is too poor to be used for real calculations (old > multiplicative stuff inside). If you want real comparison I would advise > you to run the Whetstone test. If you need the source, drop me an Email. > Also I don't think that the speed should be the only consideration when > choosing the language. Delphi provides best-on-the-market environment, > but I would consider several other issues before porting a FORTRAN > program into a new language. For example, if you have a lot of > subroutines taking 2D arrays and their dimensions as arguments it's > going to be a real pain to convert them into Pascal. Conversion to C is > much easier (and you can use fort2c to do much of the job). If you don't > want to give up the user-friendly environment of Delphi, consider > Borland's C++ builder: it's Delphi-2 sister-product with the only > difference that it employs C++ instead of Pascal. > Good luck, > -- > Eugene I Levin > Bielefeld, Germany > I'm sorry for coding my Email in the header. > Here is the right one:
|
Mon, 03 Jan 2000 03:00:00 GMT |
|
|
|