Forum Discussion

emathew's avatar
emathew
New Contributor
12 years ago

CPUUsage Property specific to 64-bit/32-bit?


Hi, 

I have a doubt regarding the CPUUsage property. I am using it for calculating the CPU Usage of a process, ie, Sys.Process(...).CPUUsage;

I see that the value crosses 100%, eg. 106%,135%,etc. Could this be due to a 64-bit operating system and if so is there a necessity to divide it by 2? 

This doubt came up as I see that the elapsetime obtained using stopwatch function also returns exactly double the time due to which we are dividing it by two:





var StopWatchObj = HISUtils.StopWatch;

StopWatchObj.Start();

StopWatchObj.Stop();

.....

....

....       

var elapsetime = StopWatchObj.Split();





Please guide me if I am wrong.

Hope to see a response soon.





Thanks,

Eyme

4 Replies

  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)
    Hi Eyme,



    I have a doubt regarding the CPUUsage property. I am using it for calculating the CPU Usage of a process, ie, Sys.Process(...).CPUUsage; I see that the value crosses 100%, eg. 106%,135%,etc.
    Could you please open a support ticket for our Support Team to look further into this? Please include the MSINFO32 report in your submission. To generate the report, follow the steps below:

    * Run the msinfo32 utility via Start | Run.

    * Select the System Summary node.

    * From the main menu, select File | Save and save the report as an *.NFO file.

    Then, attach this file to the support request form.





    This doubt came up as I see that the elapsetime obtained using stopwatch function also returns exactly double the time due to which we are dividing it by two:

    var StopWatchObj = HISUtils.StopWatch; StopWatchObj.Start(); StopWatchObj.Stop(); ..... .... .... var elapsetime = StopWatchObj.Split();
    The Split() method returns the time passed since Start(), that is the time between Start() and Split() rather than the time between Start() and Stop(). That's why, the value is larger than you expected.



    The time between Start() and Stop() can be obtained as the return value of Stop():

  • emathew's avatar
    emathew
    New Contributor
    Hi Helen,



    Thanks for the reply. I have opened a request as mentioned,request ID: M0100908.

    I tried the function using stop instead of split but unfortunately it still didn't work.

    var elapsetime = StopWatchObj.Stop();

    It still returns double the time, eg. 3.2 hrs in place of 1.6 hrs.



    Hence, I have added the same in the request too.



    Thanks,

    Eyme
  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)
    Hi Eyme,



    I have opened a request as mentioned,request ID: M0100908.
    Our support engineers will review your case and get back to you as soon as they can.



    I tried the function using stop instead of split but unfortunately it still didn't work.

    var elapsetime = StopWatchObj.Stop();

    It still returns double the time, eg. 3.2 hrs in place of 1.6 hrs.
    I've reproduced the issue - it happens when Stop() is called twice rather than once. I've forwarded this to our developers for investigation. Thanks for bringing this to our attention!



    To avoid the issue, please make sure to use only one Stop() call per each Start() call, as follows:

    var StopWatchObj = HISUtils.StopWatch;

    StopWatchObj.Start();

    ...

    var elapsetime = StopWatchObj.Stop();

    ...

    Log.Message(elapsetime);
  • emathew's avatar
    emathew
    New Contributor
    Thanks Helen, that actually worked! Now awaiting their response on the ticket I opened regarding CPU.



    Eyme