After posting a rant about Windows Vista, I thought about a way to separate perceptions from facts. In particular, I was wondering how to prove the perception that file copy operations are slow. So I fired up Delphi, added three buttons to a form, and wrote for each of them a file copy API call, like the following:

  CopyFile('small.txt', 'newsmall.txt', False);

I executed this operation 100 times in a loop, wrote a large file copy one (same code, different file), added same bare bone timing and logging code, created the two sample text files (2KB and 2MB), and started running the program on Vista. The resulting is somewhat shocking, but does confirm some perceptions:

smallx100:00:04.813
smallx100:00:00.060
smallx100:00:00.061
smallx100:00:00.061
smallx100:00:00.062
smallx100:00:00.085
smallx100:00:00.061
smallx100:00:04.833
smallx100:00:00.108
smallx100:00:00.062
smallx100:00:00.063
smallx100:00:07.192
smallx100:00:00.063
smallx100:00:00.061
smallx100:00:00.059
smallx100:00:00.061
smallx100:00:00.064
smallx100:00:12.632
smallx100:00:00.071
smallx100:00:00.078
smallx100:00:00.063
smallx100:00:00.069
smallx100:00:00.063
smallx100:00:00.063

As you can see from the log above, the same operation (copying the same file 100 times) is an average quite fast, but occasionally gets incredibly slow. How can a 60 milliseconds operation take 12 seconds? It might be this happens when the indexing engine kicks in. Let's compare this with the same program running on Windows XP on a similar hardware:

smallx100:00.00.031
smallx100:00.00.031
smallx100:00.00.047
smallx100:00.00.032
smallx100:00.00.031
smallx100:00.00.031
smallx100:00.00.031
smallx100:00.00.032
smallx100:00.00.032
smallx100:00.00.031
smallx100:00.00.031
smallx100:00.00.032
smallx100:00.00.031
smallx100:00.00.031
smallx100:00.00.031
smallx100:00.00.031
smallx100:00.00.031
smallx100:00.00.032
smallx100:00.00.031
smallx100:00.00.032
smallx100:00.00.031
smallx100:00.00.031
smallx100:00.00.031
smallx100:00.00.031
smallx100:00.00.031
smallx100:00.00.031
smallx100:00.00.031
smallx100:00.00.031
smallx100:00.00.031
smallx100:00.00.031
smallx100:00.00.031
smallx100:00.00.032
smallx100:00.00.031
smallx100:00.00.031
smallx100:00.00.031
smallx100:00.00.032
smallx100:00.00.032
smallx100:00.00.031
smallx100:00.00.031
smallx100:00.00.031
smallx100:00.00.032
smallx100:00.00.032
smallx100:00.00.031
smallx100:00.00.031
smallx100:00.00.031
smallx100:00.00.031
smallx100:00.00.031
smallx100:00.00.032
smallx100:00.00.032
smallx100:00.00.031
smallx100:00.00.031
smallx100:00.00.032
smallx100:00.00.031

Notice anything? It is about twice as fast than the best Vista results (might depend on the hard drive, as well, but probably not only), but it is way more consistent: it takes always the same amount of time, with one single exception (the third value). You won't believe this is the same program and all it does is a single API call. I've tried with a themed and a non-themed application, but this doesn't seem to make a difference. However, running it at different times, the slow peaks are not always present. Still, the timing keep floating in a rather large range...

I made another test, what about running the program on the XP machine from the Vista one? Beside the warning at start up (running a program on the network is a dangerous activity these days), the program is much slower as it has to do network file operations, but the numbers are again very consistent:

smallx100:00:00.946
smallx100:00:00.926
smallx100:00:00.910
smallx100:00:01.100
smallx100:00:00.930
smallx100:00:01.106
smallx100:00:00.908
smallx100:00:01.111
smallx100:00:00.915
smallx100:00:00.918
smallx100:00:00.906
smallx100:00:00.923

A final test: What about disabling the indexing service on Vista? I disabled Windows Search service and got the following:

smallx100:00:00.060
smallx100:00:00.060
smallx100:00:00.059
smallx100:00:00.053
smallx100:00:00.177
smallx100:00:00.058
smallx100:00:00.054
smallx100:00:00.057
smallx100:00:00.052
smallx100:00:00.056
smallx100:00:00.059
smallx100:00:00.053
smallx100:00:00.211
smallx100:00:00.059

It is not it! I disabled most other Windows Vista services, and the results kept varying from execution to execution... in other words, by trial and experiment I found no way to make the program work as it does on XP. Do you want to try? I've made the program and two sample file (with part of the source code) are available in this ZIP file. Let me know if you see the same inconsistent numbers...