File Performance Q.?
Jimmie Houchin
jhouchin at texoma.net
Fri May 10 20:12:14 UTC 2002
My apologies I neglected to mention that the testfile is simply one of
my mailboxes (text) which is 4.87mb in size.
Jimmie Houchin wrote:
> I ran a couple of simple tests to compare relative speed between Python
> and Squeak on something I've done before.
>
> The tests are very simple and are not meant to imply anything.
> I simply opened a file read it line by line writing each line to a new
> file.
>
> All tests were conducted on the same machine after fresh restarts with
> no other software running except that which is always loaded upon
> restart. The machine is a PII 266 with WinME.
> Below are the tests and code.
>
> I was naively expecting Squeak to be faster but was very surprised.
> Python's results are in seconds and Squeak's in milliseconds.
>
> Am I doing something wrong in the Squeak code to cause it to be up to
> 100 times slower? Or is this a case of the best tool for the job?
>
> Any help or comments appreciated.
>
> Jimmie Houchin
>
> Python Tests:
> FileTest.py
> import time
>
> def fileTest():
> beginningTime = time.time()
> file1 = 'c:\\jimmie\\test\\testfile.txt'
> file2 = 'c:\\jimmie\\test\\testfile2.txt'
>
> oldfile = open(file1, 'r')
> newfile = open(file2, 'w')
>
> for line in oldfile.readlines():
> newfile.write(line)
> newfile.flush()
>
> oldfile.close()
> newfile.close()
>
> finalTime = time.time()
> totalTime = finalTime - beginningTime
> print totalTime
>
>
> Python 2.2 (#28, Dec 21 2001, 12:21:22) [MSC 32 bit (Intel)] on win32
> Type "copyright", "credits" or "license" for more information.
> IDLE 0.8 -- press F1 for help
> >>> import FileTest
> >>> FileTest.fileTest()
> 5.55000007153
> >>> FileTest.fileTest()
> 4.50999999046
> >>> FileTest.fileTest()
> 4.23000001907
> >>> FileTest.fileTest()
> 4.33999991417
> >>> FileTest.fileTest()
> 4.27999997139
> >>> FileTest.fileTest()
> 2.97000002861
> >>> FileTest.fileTest()
> 2.96000003815
> >>> FileTest.fileTest()
> 2.97000002861
>
>
>
>
>
> Squeak Tests
> Squeak 3.2gamma4811
> In a workspace
>
> Transcript show:
> [file1 := CrLfFileStream new.
> file2 := CrLfFileStream new.
> file1 open: 'c:\jimmie\test\testfile.txt' forWrite: false.
> file2 open: 'c:\jimmie\test\testfile2.txt' forWrite: true.
>
> [file1 atEnd] whileFalse:
> [file2 nextPutAll: file1 nextLine.
> file2 nextPutAll: String cr].
>
> file2 flush.
> file2 close.
> file1 close] timeToRun.
>
> In the Transcript:
> 304141
> 298161
> 302502
More information about the Squeak-dev
mailing list
|