FileTest Comparisons
Jimmie Houchin
jhouchin at texoma.net
Wed Feb 19 05:34:00 UTC 2003
Here are the results for Debian Sid on a 700mzh Athlon.
Unix 3.5.1 devel i686 VM, 3.5a (updated) image.
Code below.
FileStream code:.........
timeToRun = 948
timeName = 696
timeNPA = 113
timeFlush = 2
timeClose = 117
totalTimes = 928
timeToRun = 674
timeName = 461
timeNPA = 74
timeFlush = 6
timeClose = 113
totalTimes = 654
timeToRun = 563
timeName = 414
timeNPA = 59
timeFlush = 4
timeClose = 71
totalTimes = 548
AsyncFile code:.........
timeToRun = 254
timeAFNew = 4
timeOpen = 127
timeWrite = 79
timeClose = 27
totalTimes = 237
timeToRun = 258
timeAFNew = 6
timeOpen = 129
timeWrite = 79
timeClose = 20
totalTimes = 234
timeToRun = 267
timeAFNew = 3
timeOpen = 135
timeWrite = 83
timeClose = 29
totalTimes = 250
On Linux it (AsyncFile) appears to fill all files properly.
No empty files. :)
Jimmie Houchin
Andreas Raab wrote:
> Jimmie,
>
> I'm very interested in these results, in particular the difference
between
> the "regular" and async files on Windows. That seems *very* surprising to
> me... do you have any chance to measure where exactly the difference
comes
> from (e.g., is it in opening, writing, or closing)?! The reason I'm
> wondering is that as far as the code is concerned there should be no
> difference whatsoever between the two. If there is, then I'm making some
> *rather* big mistake somewhere deep down below.
>
> Cheers,
> - Andreas
Hello Andreas,
Below is my new code to test problem spots (timings).
First here are the results from my code.
FileStream tests ....................................
timeToRun = 17415
timeName = 1489
timeNPA = 80
timeFlush = 15734
timeClose = 103
totalTimes = 17406
timeToRun = 17388
timeName = 1537
timeNPA = 92
timeFlush = 15672
timeClose = 74
totalTimes = 17375
timeToRun = 15937
timeName = 1492
timeNPA = 82
timeFlush = 14256
timeClose = 95
totalTimes = 15925
AsyncFile tests ......................................
timeToRun = 996
timeAFNew = 0
timeOpen = 683
timeWrite = 131
timeClose = 162
totalTimes = 976
With 105 empty files.
timeToRun = 1063
timeAFNew = 1
timeOpen = 724
timeWrite = 147
timeClose = 175
totalTimes = 1047
With 142 empty files.
timeToRun = 1027
timeAFNew = 2
timeOpen = 711
timeWrite = 126
timeClose = 166
totalTimes = 1005
With 139 empty files.
The AsyncFile code consistently did not writeBuffer 10-15% of the time.
I don't know if I am doing something wrong or what.
It seems as if #flush is the big spender.
I hope this helps.
Jimmie Houchin
New Testing Code: ........................................
| string filedir timeName timeNPA timeFlush timeClose |
string := 'Hello World!'.
filedir := FileDirectory default fullName, '\testfiles\'.
timeName := 0.
timeNPA := 0.
timeFlush := 0.
timeClose := 0.
Transcript show: 'timeToRun = ', [1 to: 1000 do: [:index |
t1 := [fname := FileStream newFileNamed: filedir, index asString]
timeToRun.
t2 := [fname nextPutAll: string] timeToRun.
t3 := [fname flush] timeToRun.
t4 := [fname close] timeToRun.
timeName := timeName + t1.
timeNPA := timeNPA + t2.
timeFlush := timeFlush + t3.
timeClose := timeClose + t4.]] timeToRun asString; cr.
Transcript show: 'timeName = ', timeName asString; cr.
Transcript show: 'timeNPA = ', timeNPA asString; cr.
Transcript show: 'timeFlush = ', timeFlush asString; cr.
Transcript show: 'timeClose = ', timeClose asString; cr.
Transcript show: 'totalTimes = ', (timeName + timeNPA + timeFlush +
timeClose) asString; cr.
| string2 filedir2 timeAFNew timeOpen timeWrite timeClose |
string2 := 'Hello World!'.
filedir2 := FileDirectory default fullName, '\testfiles\'.
timeAFNew := 0.
timeOpen := 0.
timeWrite := 0.
timeClose := 0.
Transcript show: 'timeToRun = ', [1 to: 1000 do: [:index |
t1 := [fname := AsyncFile new] timeToRun.
t2 := [fname open: filedir2, index asString forWrite: true] timeToRun.
t3 := [fname writeBuffer: string2 atFilePosition: 0 onCompletionDo:[]]
timeToRun.
t4 := [fname close] timeToRun.
timeAFNew := timeAFNew + t1.
timeOpen := timeOpen + t2.
timeWrite := timeWrite + t3.
timeClose := timeClose + t4.]] timeToRun asString; cr.
Transcript show: 'timeAFNew = ', timeAFNew asString; cr.
Transcript show: 'timeOpen = ', timeOpen asString; cr.
Transcript show: 'timeWrite = ', timeWrite asString; cr.
Transcript show: 'timeClose = ', timeClose asString; cr.
Transcript show: 'totalTimes = ', (timeAFNew + timeOpen + timeWrite +
timeClose) asString; cr.
>>-----Original Message-----
>>From: squeak-dev-bounces at lists.squeakfoundation.org
>>[mailto:squeak-dev-bounces at lists.squeakfoundation.org] On
>>Behalf Of Jimmie Houchin
>>Sent: Tuesday, February 18, 2003 9:07 PM
>>To: The general-purpose Squeak developers list
>>Subject: FileTest Comparisons
>>
>>
>>Before writing for help regarding Socket serving I wrote some
>>tests to
>>check Squeak performance when simply streaming to files
>>instead of sockets.
>>
>>Then I compared with similar Python code.
>>
>>Below are the results and code.
>>
>>Both Squeak and Python are slower on my WinXP machine.
>>The WinXP machine is technically almost 3X as fast as my
>>Debian machine.
>>I wish I had Linux installed on that machine to test. Maybe soon.
>>
>>The Squeak code on the Windows machine is very slow. (with FileStream)
>>I attempted AsyncFile to try to speed things up and it did
>>quite a bit
>>on Windows and some on Linux. But it failed to write out its
>>buffer to
>>all (missed about 20%) the 1000 files. It created all the files, just
>>didn't fill them.
>>
>>Is the AsyncFile code going to be about the fastest way to do
>>something
>>like this? I don't even know if I am quite using the
>>AsyncFile properly.
>>
>>Suggestions, reasons, comments welcome.
>>
>>Jimmie Houchin
>>
>>
>>Windows XP Home (Athlon XP 2000) results:
>>Squeak Results with FileStream: (ms) 17208 17441 17197
>>Squeak Results with AsyncFile: (ms) 1018 966 1050
>>Python Results: (seconds) .718 .781 .922
>>
>>Debian Linux (700mhz Athlon) results:
>>Squeak Results with FileStream: 749 579 679
>>Squeak Results with AsyncFile: 550 244 431
>>Python Results: (seconds) .445 .432
>>
>>
>>Squeak Code
>>| string filedir |
>>string := 'Hello World!'.
>>filedir := FileDirectory default fullName, '\testfiles\'.
>>
>>Transcript show: [1 to: 1000 do: [:index |
>> fname := FileStream newFileNamed: filedir, index asString.
>> fname nextPutAll: string.
>> fname flush.
>> fname close.]] timeToRun.
>>
>>| string2 filedir2 |
>>string2 := 'Hello World!'.
>>filedir2 := FileDirectory default fullName, '\testfiles\'.
>>
>>Transcript show: [1 to: 1000 do: [:index |
>> fname := AsyncFile new.
>> fname open: filedir2, index asString forWrite: true.
>> fname writeBuffer: string2 atFilePosition: 0 onCompletionDo:[].
>> fname close.]] timeToRun.
>>
>>
>>
>>Python Code:
>>fileTest.py
>>import os, time
>>
>>fdir = os.getcwd() + '/testfiles/'
>>fstring = 'Hello World!'
>>
>>
>>def test(rnumber):
>> t1 = time.time()
>> r = range(rnumber)
>> for x in r:
>> fname = open(fdir+`x`,'w')
>> fname.write(fstring)
>> fname.flush()
>> fname.close()
>> t2 = time.time()
>> print t2 - t1
More information about the Squeak-dev
mailing list
|