Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
for performance, what's the best variable type to use for boolean _TRUE & _FALSE ?
#11
(09-20-2025, 11:46 PM)NakedApe Wrote: "Unclothed monkey buddy," LOL!  Well who knew I had to clean up a link based on a search term. Man, there's all kindza ways to mess up around here. Wink  Duly noted...

Like most of my code:  Works perfectly; not as intended.  Big Grin
Reply
#12
@madscijr
about the citation of Steve
educative program showing SPEED QB64pe rules

thread from which it arises
Reply
#13
There are three factors here.

1. Quickest Load/Store at small scale
In QB64, loading or storing a
  • 64 bit long type _INTEGER64 or Double takes the fewest CPU clock cycles on most processors.
  • 1 bit type _BIT takes the most CPU clock cycles on some processors. That is due to extra instructions to calculate, mask and maybe shift to use and the instructions to calculate, load, mask, and save to store the value.

2. Maximum problem size that can be handled
A large array of type _BIT may fit in memory when an array with larger elements would not.

Code: (Select All)
_Define I-N As _INTEGER64
_Define A, C-H, O-Z As DOUBLE  ' 64 bit float
_Define B As _BIT  'Choice of:  _BIT, _BYTE, INTEGER, LONG, _INTEGER64  using  1, 8, 16, 32, or 64 bits

bFalse = 0
bTrue = Not bFalse

ksize = 2000000000
ReDim bitarray(ksize)


3. Cache Hits performance advantage
When the "working set" of executable code and data fit entirely in cache, the program runs quicker.
This may not matter for I/O bound programs, but certainly does for CPU bound programs.
  1. If it all fits in L1 cache, astounding.
  2. If it all fits in L1+L2 cache, wonderful.
  3. If it all fits in L1+L2+L3 cache, excellent.
In my recent application, at all problem sizes above ksize=1000000, _BIT outperformed larger sized array elements.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question Experimenting with a "StringList" type for simpler handling of string arrays/lists Heimdall 18 1,183 12-19-2025, 12:51 PM
Last Post: Heimdall
  performance drop on LINUX with PSET in v4.2 Herve 12 942 11-20-2025, 02:00 PM
Last Post: SpriggsySpriggs
  Loading from file into _MEM? and LEN a TYPE... Unseen Machine 9 958 08-03-2025, 02:55 AM
Last Post: SMcNeill
  Need help with boolean Petr 6 1,122 11-17-2024, 06:57 AM
Last Post: TempodiBasic
  QB64's TYPE / END TYPE inquiry MystikShadows 2 890 06-30-2024, 02:34 PM
Last Post: MystikShadows

Forum Jump:


Users browsing this thread: