View previous topic :: View next topic |
Author |
Message |
dmonckton Contributor
Joined: 09 Aug 2002 Posts: 117 Location: Lewes, U.K.
|
Posted: Thu Jun 11, 2015 9:45 am Post subject: Frequent API calls |
|
|
Hi
I'm working on a MIDI project that requires me to make a lot of API calls many times per second. Should I load the Library at the start of the script and unload it at the end, or should I load the library just before the API call and the unload just after?
Code: |
rem %1 = handle
:clockPulse
if @null(%1)
exit
end
rem handle
%%handle = %1
rem 0xF8 is the timing clock status,needs to be padded out to 4 bytes
%%data = $000000F8
loadlib winmm.dll
%z = @lib(winmm.dll,midiOutShortMsg,INT:,INT:%%handle,INT:%%data)
freelib winmm.dll
exit
|
I will be using this function every 25 milliseconds. So calling efficiency is important. Should I load winmm.dll at the start of the script and leave it in memory until the end? |
|
Back to top |
|
|
Garrett Moderator Team
Joined: 04 Oct 2001 Posts: 2149 Location: A House
|
Posted: Thu Jun 11, 2015 5:22 pm Post subject: |
|
|
I used to always load the library at the beginning of the script and close when the user closed my program.
Constatnly opening and closeing the library lagged my programs down too slow.
~Garrett _________________ 'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.) |
|
Back to top |
|
|
dmonckton Contributor
Joined: 09 Aug 2002 Posts: 117 Location: Lewes, U.K.
|
Posted: Sun Jun 14, 2015 8:22 am Post subject: |
|
|
Thanks Garret
I've changed my MIDI library to reflect your advice. I'm going to start testing my script today, fingers crossed!
One of the reasons I'm still using VDS is its ability to make API calls fairly easy.
Quote: |
I used to always load the library
|
Past tense? Your don't do API calls anymore or your don't use VDS anymore?
Regards
David |
|
Back to top |
|
|
Garrett Moderator Team
Joined: 04 Oct 2001 Posts: 2149 Location: A House
|
Posted: Sun Jun 14, 2015 4:58 pm Post subject: |
|
|
Just haven't done much programming at all these days.
I don't have any Windows computers anymore, I'm all Linux here and with only a few select programs that are run through WINE... Though, they are VDS made programs that every so often I do need to update. So VDS is installed. _________________ 'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.) |
|
Back to top |
|
|
|