lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> > I had a quick glance at the Performance Monitoring chapter of MSDN and I
> > still don't know what information it provides... I think I will give up
as it is
> > non vital.
> 
> 	http://www.google.com/search?q=rdtsc
> 
> I think it might help.
> 
> []s
>  Léo

Mmm, I though QueryPerformanceCounter used the RDTSC instruction but more
investigation shown me otherwise. I see, for example,
http://www.codeproject.com/datetime/ccputicker.asp and
http://www.gamasutra.com/features/wyatts_world/19990709/processor_detection_03.htm (for those interested).

OK, it is probably more accurate, but it shows the CPU time spent during the
execution of the process, not the CPU time spent by the process... Or I can
be wrong.
Actually, I am not even sure it is possible on Windows. At least not in a
portable fashion, since Win9x isn't purely pre-emptive, so Windows probably
don't track accurately which process is running at a given time.

Luiz Carlos Silveira  wrote:
> > It is seems very useful, but still rely on clock() or
> > times(). I can replace
> > them with Win32 functions, but I still wonder what are the
> > functions to
> > profile an application (ie. to get its CPU time).
> 
> 
> Are you sure clock() doesn't measure the CPU time on windows? I think it
does.
> 
> Running a small test will check it out:
> 
> lua -e "s=clock() read() print(clock()-s)"
> 
> run this and, when you press enter, the time will show up. If clock()
measures the CPU time given to the process, each run of this
> program will give almost the same results (0 for sure), no matter how long
you wait to press enter on each one.

Well, I am sure of nothing, but the source of the clock() function shows the
use of the system time...
And yes, I did a similar test, and as I said, running times vary from an
execution to the other, either with clock() or my functions using the high
resolution timer.
Oh wait, I see your point. Testing your example, first run, I get 4.636,
second run I type this and then I get... 49.461... Point proven. Good test :-)

> this way, HD access (or floppy or a socket) that you mentioned some emails
ago won't count to clock(), so you don't need to "reset
> the filesystem chache" of your machine.

I am not sure to agree with you here.
Say I read a file line by line. The first time I run this program, Windows
will read the file on the disk. I think this file will be on a cache (but I am
not a specialist here). So on the second run, Windows will indeed read the
file from memory, much faster.
When I do a recursive search, say with Visual Studio, on a lot of sources,
it is quite slow the first time, and very fast the next pass.


Anyway, this is going probably too much off topic, so I suggest we give up
this thread, unless it is generally useful for Lua users (gamers?).

Thank you for the suggestions and answers.

Regards.

-- 
--=#=--=#=--=#=--=#=--=#=--=#=--=#=--=#=--=#=--
Philippe Lhoste (Paris -- France)
Professional programmer and amateur artist
http://jove.prohosting.com/~philho/
--=#=--=#=--=#=--=#=--=#=--=#=--=#=--=#=--=#=--

GMX - Die Kommunikationsplattform im Internet.
http://www.gmx.net