Contributions
Re: Timer event fires irregurarly
I must say that your replies are extremely helpful :) I've read quite a lot about WMI and also confirmed that all the data I need to gather is accessible through WMI objects (and I also know the name of the ones I need). I have now started to look into the different ways to go: Use perfmon in a GUI scripted manner Use perfmon via logman from the command line Use WMI to gather data inside the script, without the use of any external application. My conclusions regarding the above so far are the following: It's easy but pretty unsafe to use the perfmon GUI, since the script is sensitive to unexpected and unfocused windows, components being disabled etc. The settings are quite complex to set ut since you either have to create script routines for that or work on the XML templates. It's both easier and safer to use logman to launch perfmon, since there's no graphical interference when performaing starting and stopping actions. I guess the settings are just as complex to manage as the previous - guess it'll be have to be done in the same way. WMI objects are equally easy to use as logman - just run it from the script. The major issue lies in the fact that the WMI objects seems to need to updated explicitly and periodically in order to get monitoring data. The two previous alternatives leave that task to the perfmon process. I've done some more testing with timer accuracy in my scripts and have come to the conclusion that they don't really become any more accurate with longer intervals either (tested 60 and 120 second intervals on 50 minute runs). So I have excluded timers as a part of the WMI implementation. The alternative solution I've found is to log on events in the tested application. This is something that has been requested from my implementation and it seems like a nice solution. The only problem here is that if the application runs without having any user interactions I guess no subscribed events will be fired and caught by TC, which will create large "blanks" in the log during i.e. data processing sessions where the application may be busy for several hours. My conclusion at this moment is that WMI objects are the preferred way to go if I can find any way go get a reliable way of performing some occasional periodical testing for those times that doesn't have events that can cause logging. Timers doesn't seem to work for my testing at all - their accuracy is really terrible :) Maybe it's possible to subscribe/listen to some more "rare"/"unusual" events that fire very often, but usually aren't of interest, and use them as a replacement for timer events? I guess .NET applications have hundreds of various kinds of events being fired every second, but only a fraction of them are of interest to me as a tester. But if I would take interest in some of these, they could provide me with regular logging pauses. It may be worth pointing out that I don't really need super accuracte timings on my monitoring - I just want to be able to always make sure that I monitor data once in a while. But my tests with timers show that they are unreliable and therefore I need some way of getting periodic monitoring measurements.1.9KViews0likes0CommentsRe: Timer event fires irregurarly
Thank you very much for your reply :) I'm running automated endurance/stress tests on a desktop application and want to log information about that process and the hardware utilization. So it seems like it won't be easy to get well-timed readings by using timers, based on your trying in getting correctly fired events in a simple application such as Notepad. I started looking into Performance Monitor after I concluded that the timer objects won't give me the precision I need, since it's also not giving me reproducable results by firing at "random". I looked for possibilites to run perfmon from withing TC, but didn't really find anything. Therefore I did a simple automation script for starting monitoring via the GUI, which is where I'm currently at. However, your way of calling perfmon from within the script sure looks interesting, especially the fact that you can access measured data so easily :) How do I learn about using the WMI service in this manner? How/where do I learn how to use and what to access in the perfmon process? When using the perfmon GUI, there are tonnes of performance counters to choose from, and I figure that not all of these can be active... The most important question might be if it's possible to just start perfmon from withing TC in this manner, and then let perfmon do its thing and log data in a way that I tell it do, instead of me collecting data into variables inside the script? 'Cause I guess I'll fall back into the timer accuracy issues again if I start collecting monitoring data from the perfmon process in TC (since this would correspond to my initial approach described in the first post). So would it be possible to just call perfmon and set certain parameters for deciding what it should monitor, and then let it run by itself without having to gather data from it through the script? I have started working with Excel sheets and charts that visualize my gathered data, so I don't really have a need for keeping the monitored data inside of TC. An alternative approach that crossed my mind earlier, when dealing with the non-accurate timers, was to do an asynchronous call to a logging function that locked its control flow inside a never-ending loop that only return when the process it monitors is dead. This loop would then sleep/delay for a specific time interval and thus act as a monitor. The issue about this quite ugly approach was that it didn't seem to be possible to call script unit functions - only object methods/properties.1.9KViews0likes0CommentsRe: Timer event fires irregurarly
But how come it's so easy to get my requested functionality in any regular programming language? Because my regular programs use operating systems too. And it's possible to make this kind of timers in JavaScript. But apparently not in TC's jScript engine? I have built timers both in more high- and low level languages/environments than this one, but never seen this kind of thing happen before. My expectations are based upon the common behaviour of timers in general. I know that they don't always are 100% accurate, but this timing behaviour is just embarrising IMO.1.9KViews0likes0CommentsTimer event fires irregurarly
I'm trying to create a simple performance logging function in my script tests. What I want to do is to set a timer that will call this logging function regularly during the entire program run, and each time the function is called it writes CPU- and memory usage of the process to a simple text document. What I have now is this, in my setup function that is called in the beginning of the test: var performanceTimer = Utils.Timers.Add(1000, "Utils_Logging.performanceLog", true); The way I see it, the timer should fire its event once every second and call the performanceLog function every time. Or have I missed something here? In a very stripped down version of my performance logging function, this is the only thing being done: Log.Message("Performance log"); What I would expect of this is to get one such log message every second. So for a test that runs for ~20 seconds I would get ~20 performance log messages. Oddly enough, this is not what happens! I can use my last run as an example. The test unit's start time was 9:41:04 and its end time was 9.42:06, so it ran for about a minute. From my other log messages I can see that the timer was added at 9:41.30 - about half way through the test. From this, I except the callback function to be called approximately 30 times, since it's 36 seconds left of the test at this point. However, I don't get anywhere near 30 calls to this function! I only get three. At each call I write a note to the log and also a short string to a text file, so there's not much being done. The related output in the log consists of three messages posted at the following times: - 9:41:42 - 9:42:04 - 9:42:04 As you can see, two of the three messages have been sent the very same second. I just don't understand how to use the timer objects properly when they seem to operate at random. This is the one and only timer I have. The callback function just performs some simple string printing. It does not help if I increase the interval to, say 5 seconds, it's still very few calls to the function. Am I missing something or are the timer objects just completely useless?21KViews0likes8Comments