Re: A Lightweight Profiler
Please explain how to use this.
I am having tough time with using this code.
How do i pass my code file into this? How do I use this code to check a code file?
Please explain with an example.
I am in urgent need of this.
Thanks in advance.
Re: A Lightweight Profiler
It also shows an error that bar is not defined.
Please help.
Re: A Lightweight Profiler
You don't pass a code file into this, it doesn't work that way. The profiler is a class just like any other class in a project. Therefore, you could copy that first code section into any valid code page, either a new one or an existing one (the second code section is just an example, and won't run or even compile, as you found out). The class is a Singleton, which means that there can only be one instance of the class. Just by having that code in the project you can use it, there isn't anything else than needs to be done with that code.
The second piece of code is an example of how the profiler class would be used. If you have a section of code that you want to time, you add a line like this before the section of code:
ProfileTimer.TheTime.Track("b")
because the class is a Singleton, you don't have to create an instance of the ProfileTimer class, there already is one. By calling Track, you start a track with whatever name you pass it as an argumetn (b, in the example). When you call Track a second time with the same name, then the timer stops that track. You don't have to do anything with it at that time, but it is stopped. Therefore, using the class is like using a stopwatch. The first time you call Track, you start the stopwatch. The second time you call Track you stop the stopwatch. You don't have to look at the stopwatch right then, but can wait until later to look at it. That's all the ProfileTimer is doing. Call Track the first time to start, call Track a second time to stop.
If that was all the class did, there wouldn't be any point in it, because that's the exact functionality of the Stopwatch class. What I added was the names. When you pass in a string, you start timing a track with that name. It is basically the same as having a whole bank of stopwatches, each of which you can stop or start independently of all the others (though you can stop them all with StopAll). The name that you pass to the Track method is how the class tells which one to stop and which one to start. As you can see by looking at the code, there is actually only one stopwatch, for efficiency, but the class acts like there are as many stopwatches as you want, each one named based on the argument you supply to Track.
Re: A Lightweight Profiler
Thanks really helpful but you explain too much..
in short ,this is how to use it:
ProfileTimer.TheTime.Track("a")
' Your code you want to examin
ProfileTimer.TheTime.Track("a")
MsgBox(ProfileTimer.TheTime.GetString("a"))
Re: A Lightweight Profiler
Yeah, but look at my user title. I ALWAYS write too much. Whether you find the explanation useful is up to the reader.