Re: Is there a faster hi resolution timer for diy profiling



"colin" <colin.rowe1@xxxxxxxxxxxxxxxxxx> wrote in message news:kr5jj.804$WJ.216@xxxxxxxxxxxxxxxxxxxxxxx
Hi,

Im trying to time some parts of my code using the Stopwatch class,
but it is so slow, I tried the QueryPerformanceFrequency()
but this seems to be just as slow,
if I just simply call this function in a loop it takes 21 ticks
with a reported frequency of 3.5mhz
its is about 6us wich is over 12k instructions on my 2ghz cpu.
this negates the idea of having a high res timer ...

Is there any way to access the timer more directly ?
I know the cpu actually has a very high resolution timer,
it would be nice to be able to just read this value directly,
maybe il have to write a c++ library and do it in asm
thats assuming I can get the OS to grant me acces to that hardware address.

basicaly im making a diy profiler, I have a profile class
wich needs Enter(enum p) funtion at the start and a Leave()
function at the end of some functions of interest.

primarily it keeps tarck of the number of calls made,
and a lists the calling functions counts too.
it also measures the total time spent in the function and the subtracts the time spent in
subroutins to provide an actual time too.

It works pretty quick for counts but when I use the timer it is like 20 times slower,
wich although I can live with waiting 20 minutes to collect the data it does mean
that there is a considerable error for short functions,

I have added a fudge wich subtracts a fiddle value from the timer,
wich is increased by 21 ticks every times its called,
this might be close but its far from ideal.

Im trying to find out why/where its spending 75% of the cpu time in
mscorlib and mscorwks libraries, the amd codeanalyst identifies its spending
most of its time in a function called mscorwks::gc_heap::adjust_limit_clr

thanks
Colin =^.^=




Please post your code, there must be something wrong with it, QueryPerformanceFrequency()
can't take 6µsec to complete.
Note that there is no need to call QueryPerformanceFrequency(), this value exposed by the Stopwatch class.
Willy.

.



Relevant Pages

  • Re: Is there a faster hi resolution timer for diy profiling
    ... its is about 6us wich is over 12k instructions on my 2ghz cpu. ... this negates the idea of having a high res timer ... ... Please post your code, there must be something wrong with it, QueryPerformanceFrequency() ... Note that there is no need to call QueryPerformanceFrequency, this value exposed by the Stopwatch class. ...
    (microsoft.public.dotnet.languages.csharp)
  • Is there a faster hi resolution timer for diy profiling
    ... Im trying to time some parts of my code using the Stopwatch class, ... its is about 6us wich is over 12k instructions on my 2ghz cpu. ... this negates the idea of having a high res timer ... ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Is there a faster hi resolution timer for diy profiling
    ... There is no way that you are going to get access to the hardware through ... Stopwatch class calls the QueryPerformanceFrequency method through the ... its is about 6us wich is over 12k instructions on my 2ghz cpu. ... this negates the idea of having a high res timer ... ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Is there a faster hi resolution timer for diy profiling
    ... its is about 6us wich is over 12k instructions on my 2ghz cpu. ... this negates the idea of having a high res timer ... ... Please post your code, there must be something wrong with it, QueryPerformanceFrequency() ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Is there a faster hi resolution timer for diy profiling
    ... at the flag, and I dump the frequency wich is 3.7~mhz, wich ... also means its high resolution. ... ie. a high priority routine such as a hardware timer interrupt updates ... Stopwatch class calls the QueryPerformanceFrequency method through the ...
    (microsoft.public.dotnet.languages.csharp)

Loading