freebasic.net Forum Index
FreeBASIC's Official Forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log inLog in

Which data type is faster ?

 
Post new topic   Reply to topic    freebasic.net Forum Index -> Beginners
View previous topic :: View next topic  
Author Message
michel13

PostPosted: Aug 12, 2007 9:43    Post subject: Which data type is faster ? Reply with quote

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
View user's profile
Pritchard
Guru
PostPosted: Aug 12, 2007 9:53    Post subject: Reply with quote

Integer.
 
Back to top
View user's profile Send e-mail
sir_mud
Master
PostPosted: Aug 12, 2007 10:02    Post subject: Reply with quote

yea, since fbc is a 32-bit compiler Integer is most likely going to be the fastest.
 
Back to top
View user's profile Visit poster's website
Pritchard
Guru
PostPosted: Aug 12, 2007 10:13    Post subject: Reply with quote

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
View user's profile Send e-mail
sir_mud
Master
PostPosted: Aug 12, 2007 10:16    Post subject: Reply with quote

mainly because integer math is faster than non-integer math. at least on a GPCPU
 
Back to top
View user's profile Visit poster's website
michel13

PostPosted: Aug 12, 2007 11:42    Post subject: Thanks Reply with quote

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
View user's profile
Pritchard
Guru
PostPosted: Aug 12, 2007 12:08    Post subject: Reply with quote

I never heard of that problem before O.o;; I wonder if that's true. . .
 
Back to top
View user's profile Send e-mail
MichaelW
Hero
PostPosted: Aug 12, 2007 12:25    Post subject: Reply with quote

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
View user's profile
michel13

PostPosted: Aug 12, 2007 12:59    Post subject: Speed Reply with quote

I read too quickly, sorry

I was desappointed to see some FB code slower than QB !
 
Back to top
View user's profile
counting_pine
Site Admin
PostPosted: Aug 12, 2007 13:10    Post subject: Reply with quote

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
View user's profile Send e-mail
cha0s
Site Admin
PostPosted: Aug 12, 2007 21:02    Post subject: Reply with quote

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
View user's profile Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
MichaelW
Hero
PostPosted: Aug 13, 2007 4:37    Post subject: Reply with quote

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
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    freebasic.net Forum Index -> Beginners All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



sf.net phatcode