FileTest Comparisons

Jimmie Houchin jhouchin at texoma.net
Tue Feb 18 20:06:35 UTC 2003


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