Which data type is faster ?

New to FreeBASIC? Post your questions here.
Post Reply
michel13
Posts: 3
Joined: Aug 12, 2007 9:33

Which data type is faster ?

Post by michel13 »

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
anonymous1337
Posts: 5494
Joined: Sep 12, 2005 20:06
Location: California

Post by anonymous1337 »

Integer.
sir_mud
Posts: 1401
Joined: Jul 29, 2006 3:00
Location: US
Contact:

Post by sir_mud »

yea, since fbc is a 32-bit compiler Integer is most likely going to be the fastest.
anonymous1337
Posts: 5494
Joined: Sep 12, 2005 20:06
Location: California

Post by anonymous1337 »

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.
sir_mud
Posts: 1401
Joined: Jul 29, 2006 3:00
Location: US
Contact:

Post by sir_mud »

mainly because integer math is faster than non-integer math. at least on a GPCPU
michel13
Posts: 3
Joined: Aug 12, 2007 9:33

Thanks

Post by michel13 »

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.
anonymous1337
Posts: 5494
Joined: Sep 12, 2005 20:06
Location: California

Post by anonymous1337 »

I never heard of that problem before O.o;; I wonder if that's true. . .
MichaelW
Posts: 3500
Joined: May 16, 2006 22:34
Location: USA

Post by MichaelW »

"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.
michel13
Posts: 3
Joined: Aug 12, 2007 9:33

Speed

Post by michel13 »

I read too quickly, sorry

I was desappointed to see some FB code slower than QB !
counting_pine
Site Admin
Posts: 6323
Joined: Jul 05, 2005 17:32
Location: Manchester, Lancs

Post by counting_pine »

The slowdown effect can easily be seen with simple programs like this:

Code: Select all

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.
cha0s
Site Admin
Posts: 5319
Joined: May 27, 2005 6:42
Location: USA
Contact:

Post by cha0s »

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.
MichaelW
Posts: 3500
Joined: May 16, 2006 22:34
Location: USA

Post by MichaelW »

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.
Post Reply