Author Topic: BEEP makes program load faster  (Read 1103 times)

0 Members and 1 Guest are viewing this topic.

Offline mynameispaul

  • Newbie
  • Posts: 49
BEEP makes program load faster
« on: February 17, 2022, 11:22:40 am »
Just curious if anyone else has encountered this.
I was debugging a program and decided to use BEEP to know if/when a particular action was taking place.
When i started the program after inserting the BEEP function the program started a lot quicker (upon pressing F5).
Even with the function conditioned so it cannot happen (such as "IF 1 = 11 THEN BEEP") the program still loads a lot quicker.
Just as an fyi i'm using older version 1.2

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: BEEP makes program load faster
« Reply #1 on: February 17, 2022, 11:30:38 am »
Programs run faster after first compile and no or few changes.

Offline mynameispaul

  • Newbie
  • Posts: 49
Re: BEEP makes program load faster
« Reply #2 on: February 17, 2022, 11:35:56 am »
When i comment out the BEEP line, program loads slower
when i un-comment the line, loads faster

Offline tomxp411

  • Newbie
  • Posts: 28
Re: BEEP makes program load faster
« Reply #3 on: February 17, 2022, 12:38:10 pm »
I just tried it, and BEEP doesn't seem to actually make a difference. I tried it with my 900 line Trek program, and it takes about 5 seconds to launch (after taking a bit longer the first try that day. I blame a newly booted computer and freshly downloaded source files.)

I placed a BEEP on the first line of code that actually gets executed. It did not change the compile or launch time. Still about 5 seconds.
I took the BEEP back out. Still about 5 seconds.

So I tried another program: a simple 15 line keyboard test utility. Same deal. With or without BEEP, it takes about 4-5 seconds to compile and launch.

How big is your program? Do you have any includes? I'm thinking you are seeing the effects of caching or pre-compilation or some other optimization that takes effect after the first use. BEEP itself does not actually seem to make a difference to me.

Offline CharlieJV

  • Newbie
  • Posts: 89
Re: BEEP makes program load faster
« Reply #4 on: February 17, 2022, 01:04:42 pm »
I just tried it, and BEEP doesn't seem to actually make a difference.

mynameispaul is using version 1.2

Any chance of different behaviour depending on QB64 versions?  Or are you on the same version?

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: BEEP makes program load faster
« Reply #5 on: February 17, 2022, 01:52:59 pm »
There have been allot of serious changes since 1.2, 1.2 is stone age ;-))

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • Steve’s QB64 Archive Forum
Re: BEEP makes program load faster
« Reply #6 on: February 17, 2022, 05:25:20 pm »
One of the core parts of QB64 is the parts system we use.  Basically, QB64 converts BAS code into C code and then compiles it.  That's a LOT of code to convert!!

Rather than try and reinvent the wheel from scratch, where possible, we plug in and link to existing C libraries to do stuff for us.  We didn't write our own font, sound, image routines from scratch -- each one of those is a separate "part", or separate library, in QB64.

In an attempt to keep file sizes as low as possible, and to reduce memory requirements, we *only* link to, and include, the libraries as needed.  This is what we refer to as our "Parts System".

Without *ANY* sound commands, we *never* link to, nor include, any of the sound library. 
Test this:

1) Compile: PRINT "Hello World".  View the EXE size.
2) Add a BEEP statement after that and compile.  View the EXE size.

Since BEEP is a sound command, we link our sound library and the EXE size goes up several hundred kilobytes. 

I honestly don't see any way that it could load  *faster* by increasing the size larger and taking up  more room in memory.  The only way I can picture this making a difference in speeding things up, is itf the size just happened to pass some buffer threshold with the OS.  Windows might not cache a  1MB  file in a page file, but it might a 2MB file, passing some threshold of convenience. 

If it loads faster for you, by some miraculous quirk of your system, by adding BEEP to the program, add BEEP to the program.  Just don't expect that adding a whole additional library to the executable  is going to run/load faster on other machines, or for other programs. 

What you've found is most likely a singular quirk of your system, for this singular instance.  I certainly wouldn't bank on it holding true anywhere else, or anytime again in the future.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline CharlieJV

  • Newbie
  • Posts: 89
Re: BEEP makes program load faster
« Reply #7 on: February 17, 2022, 07:02:57 pm »
One of the core parts of QB64 is the parts system we use .   (snip)

Man, that was great info.  Thanks for taking the time to write all of those details.  Awesome.

Offline Juanjogomez

  • Forum Regular
  • Posts: 117
Re: BEEP makes program load faster
« Reply #8 on: February 18, 2022, 01:36:48 am »
One thing to keep in mind with the Beep command is that if the program is run on a desktop computer that doesn't have speakers, it will fail and crash. This is because windows disables the sound card when it doesn't detect speakers.
That problem drove me crazy back in the day (why the program worked fine on some computers and not on others) and in the end I had to remove them all.
Regards

Offline RhoSigma

  • QB64 Developer
  • Forum Resident
  • Posts: 565
Re: BEEP makes program load faster
« Reply #9 on: February 18, 2022, 03:43:57 am »
One thing to keep in mind with the Beep command is that if the program is run on a desktop computer that doesn't have speakers, it will fail and crash. This is because windows disables the sound card when it doesn't detect speakers.
That problem drove me crazy back in the day (why the program worked fine on some computers and not on others) and in the end I had to remove them all.
Regards

This issue was fixed already by @FellippeHeitor on 26-Sep-2021 (Issue #187 at Github), hence it should not longer be a problem within the latest stable release 2.0.2 from 7-Nov-2021. You can get it by clicking the big 2.0.2 banner right at the head of this forum page.
My Projects:   https://qb64forum.alephc.xyz/index.php?topic=809
GuiTools - A graphic UI framework (can do multiple UI forms/windows in one program)
Libraries - ImageProcess, StringBuffers (virt. files), MD5/SHA2-Hash, LZW etc.
Bonus - Blankers, QB64/Notepad++ setup pack

Offline Juanjogomez

  • Forum Regular
  • Posts: 117
Re: BEEP makes program load faster
« Reply #10 on: February 18, 2022, 02:31:37 pm »
Thanks for the information. I did not know, I did not know it.

Offline krovit

  • Forum Regular
  • Posts: 179
Re: BEEP makes program load faster
« Reply #11 on: February 19, 2022, 02:59:38 am »
This issue was fixed already by @FellippeHeitor on 26-Sep-2021 (Issue #187 at Github), hence it should not longer be a problem within the latest stable release 2.0.2 from 7-Nov-2021. You can get it by clicking the big 2.0.2 banner right at the head of this forum page.

interesting! at this point a routine would be useful to ascertain the presence of the sound card on the pc.
And maybe somewhere there is already and it would be enough just to know where it is!

Nothing is easy, especially when it appears simple (and nothing could be as dangerous as trying to do good to others)