07-02-2022, 12:32 AM
(07-01-2022, 07:56 PM)bobkreid Wrote: Hi all,
I was looking at creating C/C++ Dll's to add functionality to QB64PE, and I was doing timings to see what would be best done in a dll vs native to QB64PE and I got some results that confused me.
I have a simple c function I created which adds 2 numbers:
...
If you want to understand what's going I would recommend taking a look in
./internal/temp/main.txtand some of the other files (But main.txt is where most of the code goes). That has the actual generated C++ which you could then compare. Sub's and Function's get their own C++ function, they're listed in that file after the main code.
That said I can offer a simple explanation - QB64 SUBs and FUNCTIONs have a variety of resource setup and cleanup that happens at the beginning and end of the generated C++ function for them. It's not necessarily slow, but since the code you're testing does so little that extra logic ends up taking significantly longer than your actual code. For slightly longer SUBs and FUNCTIONs the overhead should be less noticeable.
So your original assumption about the timings was probably correct, the issue is that the C++ function you wrote isn't really equivalent to the QB64 generated function.