So I think I’ve finally made some progress on my 0.2 release of the plugin watcher. I have successfully been able to detect the cpu time given to a specific plugin. I had originally asked for help from Roc in IRC and he had pointed me towards a macro called NS_TRY_SAFE_CALL_*.
For the past week, I had taken his information the wrong way. I began looking through the code and I saw that this macro was called a from many differant places in the code. So I decided to try and find out where they were called in the code by using the visual studio debugger and stepping through the code. Now, a combination of both me not understanding exactly what macros are or how to use them, and the fact that the visual studio debugger did nothing except go to the next line when I used the “step in” command, I assumed that this macro was actually setting some kind of flag somewhere, and that the code I was looking for actually followed one of these calls somewhere. So I spent many hours hunting down all the plugin loading code which was a massive web of calls left and right. Finally after another frustrating day of getting nowhere I read up a bit more on macros, and learned that they are actually defined with… well…. a #define. So instead of searching mxr for NS_TRY_SAFE I searched for #define NS_TRY_SAFE and sure enough I came across quite an interesting block of code, and learned that NS_TRY_SAFE_* is actually the exact function that gives the plugins cpu.
So after hitting my head off of a desk for a few minutes, I then looked up an object called PRIntervalTime. Which seems to be an interested object used for finding the amount of time passed between calls. It has a very high resolution and is very cpu friendly. I decided to place this function at the beginning and end of the macro call.
Now there is one small thing I need to look into. The problem is that there are two different macros:
NS_TRY_SAFE_CALL_RETURN
NS_TRY_SAFE_CALL_VOID
What I have gathered so far from my printouts is a few conditions:
Upon testing a flash video on newgrounds and youtube:
a) while the video is loading, NS_TRY_SAFE_CALL_RETURN was called mostly
b) After the video is loaded it seems to call both equally although if I move my mouse on over the video or I do things like drag the browser window around RETURN seems to get called much more
It seems to me like RETURN gets called when the user is causing a possible event on the plugin, and void is called when a plugin is just doing it’s thing. Although because return is also called while a plugin is loading I am not 100% sure how this works because even if I provide no event return is still called.
Anyway, it’s late and time for bed, but it seems to me like I finally have something to work with.