| View previous topic :: View next topic |
| Author |
Message |
|
|
Posted: Aug 12, 2007 9:43 Post subject: Which data type is faster ? |
|
|
I am writing a program making some search in discrete maths (i.e. searching in a graph with adjacency matrix)
Which data type is faster ?
Integer, Short, Ubyte, Long, Longint, Ubyte, etc.
I don't need much calculations other than simple addition or multiplication but I need 2 or 3-dim arrays |
| |
|
| Back to top |
|
 |
|
|
Posted: Aug 12, 2007 9:53 Post subject: |
|
|
| Integer. |
| |
|
| Back to top |
|
 |
|
|
Posted: Aug 12, 2007 10:02 Post subject: |
|
|
| yea, since fbc is a 32-bit compiler Integer is most likely going to be the fastest. |
| |
|
| Back to top |
|
 |
|
|
Posted: Aug 12, 2007 10:13 Post subject: |
|
|
| sir_mud wrote: | | yea, since fbc is a 32-bit compiler Integer is most likely going to be the fastest. | Integer's always going to be the fastest. |
| |
|
| Back to top |
|
 |
|
|
Posted: Aug 12, 2007 10:16 Post subject: |
|
|
| mainly because integer math is faster than non-integer math. at least on a GPCPU |
| |
|
| Back to top |
|
 |
|
|
Posted: Aug 12, 2007 11:42 Post subject: Thanks |
|
|
OK for Integer.
My question come from the FAQ that state :
"One area where there is a notable speed deficiency is in 32-bit console modes. While FreeBASIC is consistently on-par with other 32-bit console mode applications, 32-bit console mode operations are significantly slower than 16-bit console operations, as seen in QuickBasic."
So I suppose 32 bit integer in FB is faster anyway that 16 bit. |
| |
|
| Back to top |
|
 |
|
|
Posted: Aug 12, 2007 12:08 Post subject: |
|
|
| I never heard of that problem before O.o;; I wonder if that's true. . . |
| |
|
| Back to top |
|
 |
|
|
Posted: Aug 12, 2007 12:25 Post subject: |
|
|
| Quote: | | "One area where there is a notable speed deficiency is in 32-bit console modes. While FreeBASIC is consistently on-par with other 32-bit console mode applications, 32-bit console mode operations are significantly slower than 16-bit console operations, as seen in QuickBasic." |
In the context of this statement the 16-bit and 32-bit do not refer to data types, but to the type of code: 16-bit real mode code that uses 16-bit addressing, or 32-bit protected mode code that uses 32-bit addressing. The biggest reasons for 32-bit console mode operations being slower than 16-bit console operations are in the design decisions made by Microsoft. |
| |
|
| Back to top |
|
 |
|
|
Posted: Aug 12, 2007 12:59 Post subject: Speed |
|
|
I read too quickly, sorry
I was desappointed to see some FB code slower than QB ! |
| |
|
| Back to top |
|
 |
|
|
Posted: Aug 12, 2007 13:10 Post subject: |
|
|
The slowdown effect can easily be seen with simple programs like this:
| Code:
|
|
Dim i As Long For i = 1 To 100000 Print i Next i | Try running it in both QB and FB.
But as long as you're not constantly printing things, FB will be much faster than QB. |
| |
|
| Back to top |
|
 |
|
|
Posted: Aug 12, 2007 21:02 Post subject: |
|
|
I just want to say that it's more of the way BASIC's graphics are set up than "32-bit console operations are slower than 16-bit". Take a look at my conLib library on the forum... it's very fast, the tradeoff is that you have to "flip" before anything is on the console.
Kinda like writing to an off-screen buffer. FB can't do that since all console operations have to be immediately visible. |
| |
|
| Back to top |
|
 |
|
|
Posted: Aug 13, 2007 4:37 Post subject: |
|
|
| cha0s wrote: | | I just want to say that it's more of the way BASIC's graphics are set up than "32-bit console operations are slower than 16-bit". |
On my Windows 2000 system, the conlib speedtest application does 116 fps, a pure FB version of the code does 3 fps, and equivalent code compiled with QB45 does 181 fps. It looks to me like your library is achieving its speed mostly by replacing the Microsoft console-related functions with faster versions.
Good job, BTW. |
| |
|
| Back to top |
|
 |
|