Added Smalltalk/X micro benchmark for files and file I/O
authorJan Vrany <jan.vrany@fit.cvut.cz>
Fri, 30 Oct 2015 09:14:02 +0000
changeset 308 a09175ff8e80
parent 307 b963ac310a3e
child 309 7ee70a642b24
Added Smalltalk/X micro benchmark for files and file I/O
s/benchmarks/stx/BenchmarkCollection.st
s/benchmarks/stx/BenchmarkDictionaryLike.st
s/benchmarks/stx/BenchmarkFiles.st
s/benchmarks/stx/BenchmarkLinkedList.st
s/benchmarks/stx/BenchmarkSTX1.st
s/benchmarks/stx/BenchmarkSTX2.st
s/benchmarks/stx/BenchmarkSTX3.st
s/benchmarks/stx/BenchmarkSimpleHanoi.st
s/benchmarks/stx/BenchmarkSlopstone.st
s/benchmarks/stx/BenchmarkSmopstone.st
s/benchmarks/stx/BenchmarkSortedCollectionLike.st
s/benchmarks/stx/BenchmarkSpeedTester.st
s/benchmarks/stx/Make.proto
s/benchmarks/stx/Make.spec
s/benchmarks/stx/abbrev.stc
s/benchmarks/stx/bc.mak
s/benchmarks/stx/bmake.bat
s/benchmarks/stx/jv_calipel_s_benchmarks_stx.st
s/benchmarks/stx/libInit.cc
s/benchmarks/stx/vcmake.bat
--- a/s/benchmarks/stx/BenchmarkCollection.st	Fri Oct 30 07:19:59 2015 +0000
+++ b/s/benchmarks/stx/BenchmarkCollection.st	Fri Oct 30 09:14:02 2015 +0000
@@ -1,5 +1,7 @@
 "{ Package: 'jv:calipel/s/benchmarks/stx' }"
 
+"{ NameSpace: Smalltalk }"
+
 Benchmark subclass:#BenchmarkCollection
 	instanceVariableNames:'collectionClass collectionDatasetSize collectionDataset1
 		collectionDataset2 collectionDataset3 collection
--- a/s/benchmarks/stx/BenchmarkDictionaryLike.st	Fri Oct 30 07:19:59 2015 +0000
+++ b/s/benchmarks/stx/BenchmarkDictionaryLike.st	Fri Oct 30 09:14:02 2015 +0000
@@ -1,5 +1,7 @@
 "{ Package: 'jv:calipel/s/benchmarks/stx' }"
 
+"{ NameSpace: Smalltalk }"
+
 BenchmarkCollection subclass:#BenchmarkDictionaryLike
 	instanceVariableNames:''
 	classVariableNames:''
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/s/benchmarks/stx/BenchmarkFiles.st	Fri Oct 30 09:14:02 2015 +0000
@@ -0,0 +1,115 @@
+"{ Package: 'jv:calipel/s/benchmarks/stx' }"
+
+"{ NameSpace: Smalltalk }"
+
+Object subclass:#BenchmarkFiles
+	instanceVariableNames:'tmpdir1 filenames1'
+	classVariableNames:''
+	poolDictionaries:''
+	category:'CalipeL-S-Benchmarks-St/X'
+!
+
+
+!BenchmarkFiles class methodsFor:'running'!
+
+run
+    "Run all benchmarks in this class. Returns benchmark results as instance of BenchmarkResultC"
+
+    ^ (BenchmarkSuite class:self) run
+
+    "Created: / 10-06-2013 / 21:53:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified (comment): / 30-10-2015 / 07:05:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+run: benchmark
+    "Run benchmarks defined in method `benchmark` Returns benchmark result as instance of BenchmarkResultC"
+
+    ^ (BenchmarkInstance class:self selector:benchmark) run
+
+    "Created: / 31-05-2013 / 10:39:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 10-06-2013 / 21:53:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified (comment): / 30-10-2015 / 07:05:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+run: benchmark with: parameters
+    "Run benchmark defined in method `benchmark` with given parameters.
+     Returns benchmark results as instance of BenchmarkResultC.
+     `parameters` id a Dictionary defining parameters and theit values
+     (as strings).
+     "          
+
+    ^ (BenchmarkInstance class:self selector:benchmark) runWith: parameters
+
+    "Created: / 10-03-2014 / 00:12:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified (comment): / 30-10-2015 / 07:07:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+spy: benchmark
+    "Rum the benchmark under a Smalltalk profiler (MessageTally or whatever
+     the platform provides)."
+
+    ^ (BenchmarkInstance class:self selector:benchmark) spy
+
+    "Created: / 30-10-2015 / 07:16:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!BenchmarkFiles methodsFor:'benchmarks'!
+
+benchmarkExistsOpenReadClose
+    <benchmark: 'File: exists, open, read, close'>
+    <setup: #setupFilenames1>
+    1000 timesRepeat:[
+        filenames1 do:[:fn |
+            | readstream |
+
+            fn exists.
+            readstream := fn readStream.
+            readstream contents.
+            readstream close.
+        ].
+    ].
+
+    "
+    BenchmarkFiles run: #benchmarkExistsOpenReadClose
+    "
+
+    "Created: / 30-10-2015 / 08:00:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!BenchmarkFiles methodsFor:'setup'!
+
+setupFilenames1
+    | pkgdef pkgdir |
+
+    tmpdir1 := Filename newTemporaryDirectory.
+    pkgdef := Smalltalk at: #'jv_calipel_s'.
+    pkgdir := pkgdef packageDirectory.
+    filenames1 := pkgdef classNames collect:[ :each | 
+        | basename |
+
+        basename := each , '.st'.
+        (pkgdir / basename) copyTo: (tmpdir1 / basename).
+        tmpdir1 / basename    
+    ].
+
+    "Created: / 30-10-2015 / 07:56:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 30-10-2015 / 11:48:46 / jv"
+!
+
+teardown
+    <teardown>
+
+    (tmpdir1 notNil and:[ tmpdir1 isDirectory ]) ifTrue:[ 
+        tmpdir1 recursiveRemove.
+    ].
+
+    "Created: / 30-10-2015 / 11:49:43 / jv"
+! !
+
+!BenchmarkFiles class methodsFor:'documentation'!
+
+version_HG
+
+    ^ '$Changeset: <not expanded> $'
+! !
+
--- a/s/benchmarks/stx/BenchmarkLinkedList.st	Fri Oct 30 07:19:59 2015 +0000
+++ b/s/benchmarks/stx/BenchmarkLinkedList.st	Fri Oct 30 09:14:02 2015 +0000
@@ -1,5 +1,7 @@
 "{ Package: 'jv:calipel/s/benchmarks/stx' }"
 
+"{ NameSpace: Smalltalk }"
+
 Object subclass:#BenchmarkLinkedList
 	instanceVariableNames:''
 	classVariableNames:''
--- a/s/benchmarks/stx/BenchmarkSTX1.st	Fri Oct 30 07:19:59 2015 +0000
+++ b/s/benchmarks/stx/BenchmarkSTX1.st	Fri Oct 30 09:14:02 2015 +0000
@@ -26,6 +26,8 @@
 "
 "{ Package: 'jv:calipel/s/benchmarks/stx' }"
 
+"{ NameSpace: Smalltalk }"
+
 Benchmark subclass:#BenchmarkSTX1
 	instanceVariableNames:'iterations'
 	classVariableNames:''
--- a/s/benchmarks/stx/BenchmarkSTX2.st	Fri Oct 30 07:19:59 2015 +0000
+++ b/s/benchmarks/stx/BenchmarkSTX2.st	Fri Oct 30 09:14:02 2015 +0000
@@ -25,6 +25,8 @@
 "
 "{ Package: 'jv:calipel/s/benchmarks/stx' }"
 
+"{ NameSpace: Smalltalk }"
+
 Benchmark subclass:#BenchmarkSTX2
 	instanceVariableNames:''
 	classVariableNames:''
--- a/s/benchmarks/stx/BenchmarkSTX3.st	Fri Oct 30 07:19:59 2015 +0000
+++ b/s/benchmarks/stx/BenchmarkSTX3.st	Fri Oct 30 09:14:02 2015 +0000
@@ -1,5 +1,7 @@
 "{ Package: 'jv:calipel/s/benchmarks/stx' }"
 
+"{ NameSpace: Smalltalk }"
+
 Benchmark subclass:#BenchmarkSTX3
 	instanceVariableNames:''
 	classVariableNames:''
--- a/s/benchmarks/stx/BenchmarkSimpleHanoi.st	Fri Oct 30 07:19:59 2015 +0000
+++ b/s/benchmarks/stx/BenchmarkSimpleHanoi.st	Fri Oct 30 09:14:02 2015 +0000
@@ -1,5 +1,7 @@
 "{ Package: 'jv:calipel/s/benchmarks/stx' }"
 
+"{ NameSpace: Smalltalk }"
+
 Benchmark subclass:#BenchmarkSimpleHanoi
 	instanceVariableNames:''
 	classVariableNames:''
--- a/s/benchmarks/stx/BenchmarkSlopstone.st	Fri Oct 30 07:19:59 2015 +0000
+++ b/s/benchmarks/stx/BenchmarkSlopstone.st	Fri Oct 30 09:14:02 2015 +0000
@@ -1,5 +1,7 @@
 "{ Package: 'jv:calipel/s/benchmarks/stx' }"
 
+"{ NameSpace: Smalltalk }"
+
 Object subclass:#BenchmarkSlopstone
 	instanceVariableNames:'testParams testBlocks'
 	classVariableNames:''
@@ -499,3 +501,10 @@
 	[v := 0] value. [self] value. [v := 0] value. [v := 0] value. [v := 0] value. [v := 0] value. [v := 0] value]
 ! !
 
+!BenchmarkSlopstone class methodsFor:'documentation'!
+
+version_HG
+
+    ^ '$Changeset: <not expanded> $'
+! !
+
--- a/s/benchmarks/stx/BenchmarkSmopstone.st	Fri Oct 30 07:19:59 2015 +0000
+++ b/s/benchmarks/stx/BenchmarkSmopstone.st	Fri Oct 30 09:14:02 2015 +0000
@@ -1,5 +1,7 @@
 "{ Package: 'jv:calipel/s/benchmarks/stx' }"
 
+"{ NameSpace: Smalltalk }"
+
 Object subclass:#BenchmarkSmopstone
 	instanceVariableNames:'testParams testBlocks'
 	classVariableNames:''
--- a/s/benchmarks/stx/BenchmarkSortedCollectionLike.st	Fri Oct 30 07:19:59 2015 +0000
+++ b/s/benchmarks/stx/BenchmarkSortedCollectionLike.st	Fri Oct 30 09:14:02 2015 +0000
@@ -1,5 +1,7 @@
 "{ Package: 'jv:calipel/s/benchmarks/stx' }"
 
+"{ NameSpace: Smalltalk }"
+
 BenchmarkCollection subclass:#BenchmarkSortedCollectionLike
 	instanceVariableNames:''
 	classVariableNames:''
--- a/s/benchmarks/stx/BenchmarkSpeedTester.st	Fri Oct 30 07:19:59 2015 +0000
+++ b/s/benchmarks/stx/BenchmarkSpeedTester.st	Fri Oct 30 09:14:02 2015 +0000
@@ -1,5 +1,7 @@
 "{ Package: 'jv:calipel/s/benchmarks/stx' }"
 
+"{ NameSpace: Smalltalk }"
+
 Object subclass:#BenchmarkSpeedTester
 	instanceVariableNames:''
 	classVariableNames:''
--- a/s/benchmarks/stx/Make.proto	Fri Oct 30 07:19:59 2015 +0000
+++ b/s/benchmarks/stx/Make.proto	Fri Oct 30 09:14:02 2015 +0000
@@ -107,7 +107,7 @@
 
 
 # build all packages containing referenced classes for this package
-# they are nor needed to compile the package
+# they are not needed to compile the package (but later, to load it)
 references:
 
 
@@ -123,6 +123,7 @@
 
 # BEGINMAKEDEPEND --- do not remove this line; make depend needs it
 $(OUTDIR)BenchmarkCollection.$(O) BenchmarkCollection.$(H): BenchmarkCollection.st $(INCLUDE_TOP)/jv/calipel/s/Benchmark.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
+$(OUTDIR)BenchmarkFiles.$(O) BenchmarkFiles.$(H): BenchmarkFiles.st $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
 $(OUTDIR)BenchmarkLinkedList.$(O) BenchmarkLinkedList.$(H): BenchmarkLinkedList.st $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
 $(OUTDIR)BenchmarkSTX1.$(O) BenchmarkSTX1.$(H): BenchmarkSTX1.st $(INCLUDE_TOP)/jv/calipel/s/Benchmark.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
 $(OUTDIR)BenchmarkSTX2.$(O) BenchmarkSTX2.$(H): BenchmarkSTX2.st $(INCLUDE_TOP)/jv/calipel/s/Benchmark.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
--- a/s/benchmarks/stx/Make.spec	Fri Oct 30 07:19:59 2015 +0000
+++ b/s/benchmarks/stx/Make.spec	Fri Oct 30 09:14:02 2015 +0000
@@ -52,6 +52,7 @@
 
 COMMON_CLASSES= \
 	BenchmarkCollection \
+	BenchmarkFiles \
 	BenchmarkLinkedList \
 	BenchmarkSTX1 \
 	BenchmarkSTX2 \
@@ -69,6 +70,7 @@
 
 COMMON_OBJS= \
     $(OUTDIR_SLASH)BenchmarkCollection.$(O) \
+    $(OUTDIR_SLASH)BenchmarkFiles.$(O) \
     $(OUTDIR_SLASH)BenchmarkLinkedList.$(O) \
     $(OUTDIR_SLASH)BenchmarkSTX1.$(O) \
     $(OUTDIR_SLASH)BenchmarkSTX2.$(O) \
--- a/s/benchmarks/stx/abbrev.stc	Fri Oct 30 07:19:59 2015 +0000
+++ b/s/benchmarks/stx/abbrev.stc	Fri Oct 30 09:14:02 2015 +0000
@@ -2,6 +2,7 @@
 # this file is needed for stc to be able to compile modules independently.
 # it provides information about a classes filename, category and especially namespace.
 BenchmarkCollection BenchmarkCollection jv:calipel/s/benchmarks/stx 'CalipeL-S-Benchmarks-St/X' 0
+BenchmarkFiles BenchmarkFiles jv:calipel/s/benchmarks/stx 'CalipeL-S-Benchmarks-St/X' 0
 BenchmarkLinkedList BenchmarkLinkedList jv:calipel/s/benchmarks/stx 'CalipeL-S-Benchmarks-St/X' 0
 BenchmarkSTX1 BenchmarkSTX1 jv:calipel/s/benchmarks/stx 'CalipeL-S-Benchmarks-St/X' 0
 BenchmarkSTX2 BenchmarkSTX2 jv:calipel/s/benchmarks/stx 'CalipeL-S-Benchmarks-St/X' 0
--- a/s/benchmarks/stx/bc.mak	Fri Oct 30 07:19:59 2015 +0000
+++ b/s/benchmarks/stx/bc.mak	Fri Oct 30 09:14:02 2015 +0000
@@ -70,6 +70,7 @@
 
 # BEGINMAKEDEPEND --- do not remove this line; make depend needs it
 $(OUTDIR)BenchmarkCollection.$(O) BenchmarkCollection.$(H): BenchmarkCollection.st $(INCLUDE_TOP)\jv\calipel\s\Benchmark.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
+$(OUTDIR)BenchmarkFiles.$(O) BenchmarkFiles.$(H): BenchmarkFiles.st $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
 $(OUTDIR)BenchmarkLinkedList.$(O) BenchmarkLinkedList.$(H): BenchmarkLinkedList.st $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
 $(OUTDIR)BenchmarkSTX1.$(O) BenchmarkSTX1.$(H): BenchmarkSTX1.st $(INCLUDE_TOP)\jv\calipel\s\Benchmark.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
 $(OUTDIR)BenchmarkSTX2.$(O) BenchmarkSTX2.$(H): BenchmarkSTX2.st $(INCLUDE_TOP)\jv\calipel\s\Benchmark.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
--- a/s/benchmarks/stx/bmake.bat	Fri Oct 30 07:19:59 2015 +0000
+++ b/s/benchmarks/stx/bmake.bat	Fri Oct 30 09:14:02 2015 +0000
@@ -7,6 +7,7 @@
 @REM Kludge got Mercurial, cannot be implemented in Borland make
 @FOR /F "tokens=*" %%i in ('hg root') do SET HGROOT=%%i
 @IF "%HGROOT%" NEQ "" SET DEFINES=%DEFINES% "-DHGROOT=%HGROOT%"
+
 make.exe -N -f bc.mak  %DEFINES% %*
 
 
--- a/s/benchmarks/stx/jv_calipel_s_benchmarks_stx.st	Fri Oct 30 07:19:59 2015 +0000
+++ b/s/benchmarks/stx/jv_calipel_s_benchmarks_stx.st	Fri Oct 30 09:14:02 2015 +0000
@@ -1,5 +1,7 @@
 "{ Package: 'jv:calipel/s/benchmarks/stx' }"
 
+"{ NameSpace: Smalltalk }"
+
 LibraryDefinition subclass:#jv_calipel_s_benchmarks_stx
 	instanceVariableNames:''
 	classVariableNames:''
@@ -23,26 +25,29 @@
     "list packages which are mandatory as a prerequisite.
      This are packages containing superclasses of my classes and classes which
      are extended by myself.
-     They are mandatory, beacuse we need these packages as a prerequisite for loading and compiling.
+     They are mandatory, because we need these packages as a prerequisite for loading and compiling.
      This method is generated automatically,
      by searching along the inheritance chain of all of my classes."
 
     ^ #(
-        #'jv:calipel/s'    "Benchmark - superclass of BenchmarkCollection "
-        #'stx:libbasic'    "LibraryDefinition - superclass of jv_calipel_s_benchmarks_stx "
+        #'jv:calipel/s'    "Benchmark - superclass of BenchmarkCollection"
+        #'stx:libbasic'    "LibraryDefinition - superclass of jv_calipel_s_benchmarks_stx"
     )
 !
 
 referencedPreRequisites
     "list packages which are a prerequisite, because they contain
      classes which are referenced by my classes.
-     We do not need these packages as a prerequisite for loading or compiling.
+     We do not need these packages as a prerequisite for compiling or loading,
+     however, a class from it may be referenced during execution and having it
+     unloaded then may lead to a runtime doesNotUnderstand error, unless the caller
+     includes explicit checks for the package being present.
      This method is generated automatically,
      by searching all classes (and their packages) which are referenced by my classes."
 
     ^ #(
-        #'stx:libbasic2'    "BinaryTree - referenced by BenchmarkSortedCollectionLike class>>test_Btree "
-        #'stx:libview'    "Color - referenced by BenchmarkSTX1>>lineDrawing2 "
+        #'stx:libbasic2'    "BinaryTree - referenced by BenchmarkSortedCollectionLike class>>test_Btree"
+        #'stx:libview'    "Color - referenced by BenchmarkSTX1>>lineDrawing2"
     )
 !
 
@@ -67,6 +72,7 @@
     ^ #(
         "<className> or (<className> attributes...) in load order"
         BenchmarkCollection
+        BenchmarkFiles
         BenchmarkLinkedList
         BenchmarkSTX1
         BenchmarkSTX2
--- a/s/benchmarks/stx/libInit.cc	Fri Oct 30 07:19:59 2015 +0000
+++ b/s/benchmarks/stx/libInit.cc	Fri Oct 30 09:14:02 2015 +0000
@@ -28,6 +28,7 @@
 OBJ snd; struct __vmData__ *__pRT__; {
 __BEGIN_PACKAGE2__("libjv_calipel_s_benchmarks_stx", _libjv_calipel_s_benchmarks_stx_Init, "jv:calipel/s/benchmarks/stx");
 _BenchmarkCollection_Init(pass,__pRT__,snd);
+_BenchmarkFiles_Init(pass,__pRT__,snd);
 _BenchmarkLinkedList_Init(pass,__pRT__,snd);
 _BenchmarkSTX1_Init(pass,__pRT__,snd);
 _BenchmarkSTX2_Init(pass,__pRT__,snd);
--- a/s/benchmarks/stx/vcmake.bat	Fri Oct 30 07:19:59 2015 +0000
+++ b/s/benchmarks/stx/vcmake.bat	Fri Oct 30 09:14:02 2015 +0000
@@ -13,8 +13,9 @@
 @REM Kludge got Mercurial, cannot be implemented in Borland make
 @FOR /F "tokens=*" %%i in ('hg root') do SET HGROOT=%%i
 @IF "%HGROOT%" NEQ "" SET DEFINES=%DEFINES% "-DHGROOT=%HGROOT%"
+
+
 make.exe -N -f bc.mak -DUSEVC=1 %DEFINES% %*
 
 
 
-