Which data type is faster ?

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

Which data type is faster ?

Postby michel13 » Aug 12, 2007 9:43

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

Postby anonymous1337 » Aug 12, 2007 9:53

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

Postby sir_mud » Aug 12, 2007 10:02

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

Postby anonymous1337 » Aug 12, 2007 10:13

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:

Postby sir_mud » Aug 12, 2007 10:16

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

Postby michel13 » Aug 12, 2007 11:42

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

Postby anonymous1337 » Aug 12, 2007 12:08

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

Postby MichaelW » Aug 12, 2007 12:25

"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

Postby michel13 » Aug 12, 2007 12:59

I read too quickly, sorry

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

Postby counting_pine » Aug 12, 2007 13:10

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: 5317
Joined: May 27, 2005 6:42
Location: Illinois
Contact:

Postby cha0s » Aug 12, 2007 21:02

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

Postby MichaelW » Aug 13, 2007 4:37

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.

Return to “Beginners”

Who is online

Users browsing this forum: No registered users and 2 guests