How to get time (milisecond) of a python IO execution

Dave Angel davea at davea.name
Sun Sep 15 07:31:43 EDT 2013


On 14/9/2013 22:59, Tal Bar-Or wrote:

> Hi All
>
> i am trying to test measure some IO execution in milliseconds , but bit confuse about best method achive that under windows 7

Measuring any performance can be tricky, and I/O in particular.  Windows
will cache the recently used file information, at a few levels.  So if
you do the same thing repeatedly, you'll get an unnaturally low average
time.

if you really need to measure how long it takes to get a file size,
you would need to write your own, very controlled, test code.  For
example, there is an APi call that tells Windows to flush its disk
caching logic.  However, it doesn't necessarily flush the buffers that
the drive itself keeps.  Worse, in order to run your program, you have
to do some disk I/O, and if that happens to use some of the same sectors
as the thing you're timing, you're biasing the results.

If you have multiple partitions, you could arrange that the file in
question is the only thing your system uses on that partition, to
minimize the likelihood that something else has primed the pump.  But
realize also that once you're measuring the real thing, speed of
exeution will vary enormously depending on the speed of the drive, the
layout of the directories, and the fragmentation of the disk.


-- 
DaveA





More information about the Python-list mailing list