Windows资源管理器复制时间基准

时间:2013-02-27 16:52:10

标签: windows file batch-file benchmarking

我正在尝试对我们公司的OS进行基准测试,其中一个步骤是计算用户在资源管理器下使用ctrl-c / ctrl-v将某些内容复制到某个地方需要多长时间。 因此,我想知道如何将批处理中的该操作编写为多次运行,以便我可以获得时间执行,特别是如何使复制过程弹出窗口。我认为“rundll32 shell32.dll”在某种程度上涉及但我不知道如何。

由于

2 个答案:

答案 0 :(得分:0)

你可以

答案 1 :(得分:0)

你可以用vbscript做到这一点。请参阅Folder.CopyHere method页面上的脚本示例。有趣的是,Folder.CopyHere方法也可以将文件放入zip文件夹。请看an example(如果没有其他原因,请查看另一个如何使用CopyHere的实际示例)。与scripting.filesystemobject复制功能不同,shell.application复制功能使用Windows UI API,如果存在则提示替换,并显示文件复制对话框,就像用户拖放一样。

这是一个示例benchmark.vbs,它将".\Ubi Caritas.mp3"复制到%temp% 100次,然后显示操作所花费的时间(精确到4位)。

set wShl = CreateObject("Wscript.Shell")
tmp = wShl.ExpandEnvironmentStrings("%TEMP%")
set wShl = nothing
set oShl = CreateObject("shell.application")
set fso = CreateObject("Scripting.FileSystemObject")

set srcfile=fso.GetFile("Ubi Caritas.mp3")
dest=tmp & "\" & srcfile.Name

wscript.Echo "Testing copy speed from " & srcfile.Name & " (" & srcfile.size & " bytes) to " & dest

' single copy
msb4 = Timer
call doCopy
msafter = Timer
wscript.Echo "1 copy took " & FormatNumber(msafter - msb4, 4, -2, -2, false) & " seconds."

' 100 copies
msb4 = Timer
for i = 0 to 100
    call doCopy
next
msafter = Timer
wscript.Echo "100 copies took " & FormatNumber(msafter - msb4, 4, -2, -2, false) & " seconds."

set destfile = nothing
set oShl = nothing
set fso = nothing

sub doCopy
    oShl.namespace(tmp).copyhere(srcfile.Name), 16
    if isEmpty(destfile) then set destfile = fso.getFile(dest)
    do until destfile.size = srcfile.size
        wscript.sleep 10
    loop
    destfile.delete
end sub

示例输出:

C:\Users\me\Desktop>cscript /nologo benchmark.vbs
Testing copy speed from Ubi Caritas.mp3 (2929371 bytes) to C:\Users\me\AppD
ata\Local\Temp\Ubi Caritas.mp3
1 copy took 0.0664 seconds.
100 copies took 4.0430 seconds.