Note!!! Bug fix! The OLE/VBS test c:\temp path was missing. If you ran this script before this message was here, you will have 1000 7 byte text files in your current directory.


Speed test results:

Redirect test - 11 sec
OPEN, WRITELINE, CLOSE test - 15 sec
DOS shell test - 31 sec
OLE/VBS External Call test - 21 sec

this is creating 1000 randomly named files.

Here is the code:


WriteFileSpeedTest.KiX

code:

break on cls
; write file speed test


$iCount=1000


$sFilename=""
shell "%comspec% /c time <cr >time.txt" $=open(1, "time.txt") srnd(val(substr(readline(1), 31, 2))) $=close(1)
$iCount " files created by each method." ? ?


"Redirect test..." ?
@time ?
$i=0
do
$sFilename=chr(rnd(25)+97)+chr(rnd(25)+97)+chr(rnd(25)+97)+chr(rnd(25)+97)+chr(rnd(25)+97)+chr(rnd(25)+97)+".tst"
$=redirectoutput("c:\temp\$sFilename", 1)
"Hello" ?
$i=$i+1
until $i=$iCount
$=redirectoutput("")
@time ? ?


"OPEN, WRITELINE, CLOSE test..." ?
@time ?
$i=0
do
$sFilename=chr(rnd(25)+97)+chr(rnd(25)+97)+chr(rnd(25)+97)+chr(rnd(25)+97)+chr(rnd(25)+97)+chr(rnd(25)+97)+".tst"
$=open(1, "c:\temp\$sFilename", 5)
$=writeline(1, "Hello"+chr(13)+chr(10))
$=close(1)
$i=$i+1
until $i=$iCount
@time ? ?


"DOS shell test..." ?
@time ?
$i=0
do
$sFilename=chr(rnd(25)+97)+chr(rnd(25)+97)+chr(rnd(25)+97)+chr(rnd(25)+97)+chr(rnd(25)+97)+chr(rnd(25)+97)+".tst"
shell "%comspec% /c echo Hello> c:\temp\$sFilename"
$i=$i+1
until $i=$iCount
@time ? ?


"OLE/VBS External Call test..." ?
@time ?
$i=0
do
$sFilename=chr(rnd(25)+97)+chr(rnd(25)+97)+chr(rnd(25)+97)+chr(rnd(25)+97)+chr(rnd(25)+97)+chr(rnd(25)+97)+".tst"
$fText=val("&"+olecallfunc(olecreateobject("Scripting.FileSystemObject"), "CreateTextFile", "s", "c:\temp\"+$sFilename))
$=olecallfunc($fText, "WriteLine", "s", "Hello")
$=olecallfunc($fText, "Close")
$i=$i+1
until $i=$iCount
@time ? ?


"Deleting " $iCount*4 " files..."
del "c:\temp\*.tst"
"done" ? ? quit


cj

 

[This message has been edited by cj (edited 29 March 2001).]