Add simple `#perform:...` benchmark suggested by Eliot
authorJan Vrany <jan.vrany@fit.cvut.cz>
Sat, 25 Jan 2020 22:15:10 +0000
changeset 317 a462cd3ed353
parent 316 44346cc94ec4
child 318 1b735d3747d8
Add simple `#perform:...` benchmark suggested by Eliot in http://forum.world.st/Re-Pharo-dev-Fed-up-tt5110526.html#none
s/benchmarks/micro/BenchmarkLocking.st
s/benchmarks/micro/BenchmarkMicroStringConcat.st
s/benchmarks/micro/BenchmarkMicroStringConcatN.st
s/benchmarks/micro/BenchmarkPerformEliot.st
s/benchmarks/micro/BenchmarkSemaphore.st
s/benchmarks/micro/Make.proto
s/benchmarks/micro/Make.spec
s/benchmarks/micro/abbrev.stc
s/benchmarks/micro/bc.mak
s/benchmarks/micro/jv_calipel_s_benchmarks_micro.st
s/benchmarks/micro/libInit.cc
--- a/s/benchmarks/micro/BenchmarkLocking.st	Mon Aug 28 21:41:34 2017 +0100
+++ b/s/benchmarks/micro/BenchmarkLocking.st	Sat Jan 25 22:15:10 2020 +0000
@@ -21,6 +21,37 @@
 
 !BenchmarkLocking methodsFor:'benchmarks'!
 
+benchmarkBase
+    <benchmark: 'workload (no locks)'>
+
+    | blocker iterations body |
+
+    nesting isNil ifTrue:[ nesting := 1 ].
+    iterations := 10000000.
+    blocker := Semaphore new: (threads - 1) negated.
+    body := [
+                iterations timesRepeat:[ self workloadBase: nesting ].
+                blocker signal.
+            ].
+    1 to: threads do:[:i |
+        | t |
+
+        t := body newProcess.
+        t name: 'Benchmark ''', self class name, ' >> benchmarkBase, thread ', i printString.
+        t resume.
+    ].
+    blocker wait.
+
+    "
+    BenchmarkRecursionLock run: #benchmarkCritical.
+    BenchmarkSemaphore run: #benchmarkCritical
+    "
+
+    "Created: / 25-08-2017 / 08:46:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 28-08-2017 / 21:32:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+
+!
+
 benchmarkCritical
     <benchmark: '#critical:'>
 
@@ -81,38 +112,6 @@
     "Created: / 25-08-2017 / 08:46:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
     "Modified: / 28-08-2017 / 21:32:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 
-!
-
-
-benchmarkBase
-    <benchmark: 'workload (no locks)'>
-
-    | blocker iterations body |
-
-    nesting isNil ifTrue:[ nesting := 1 ].
-    iterations := 10000000.
-    blocker := Semaphore new: (threads - 1) negated.
-    body := [
-                iterations timesRepeat:[ self workloadBase: nesting ].
-                blocker signal.
-            ].
-    1 to: threads do:[:i |
-        | t |
-
-        t := body newProcess.
-        t name: 'Benchmark ''', self class name, ' >> benchmarkBase, thread ', i printString.
-        t resume.
-    ].
-    blocker wait.
-
-    "
-    BenchmarkRecursionLock run: #benchmarkCritical.
-    BenchmarkSemaphore run: #benchmarkCritical
-    "
-
-    "Created: / 25-08-2017 / 08:46:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 28-08-2017 / 21:32:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-
 ! !
 
 !BenchmarkLocking methodsFor:'parameters'!
@@ -126,6 +125,13 @@
 
 !BenchmarkLocking methodsFor:'private'!
 
+doSomeWork
+    1 perform: #+ with: 1
+
+    "Created: / 25-08-2017 / 09:04:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 28-08-2017 / 21:11:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 justpureCritical: n
     lock critical:[
         n > 1 ifTrue:[
@@ -137,19 +143,6 @@
     "Modified: / 28-08-2017 / 21:29:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
-
-workloadCritical: n
-    lock critical:[
-        self doSomeWork.
-        n > 1 ifTrue:[
-            self workloadCritical: n - 1.
-        ].
-    ].
-
-    "Created: / 25-08-2017 / 08:55:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 28-08-2017 / 21:29:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
 workloadBase: n
     self doSomeWork.
     n > 1 ifTrue:[
@@ -161,10 +154,15 @@
 
 !
 
-doSomeWork
-    1 perform: #+ with: 1
+workloadCritical: n
+    lock critical:[
+        self doSomeWork.
+        n > 1 ifTrue:[
+            self workloadCritical: n - 1.
+        ].
+    ].
 
-    "Created: / 25-08-2017 / 09:04:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 28-08-2017 / 21:11:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Created: / 25-08-2017 / 08:55:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 28-08-2017 / 21:29:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
--- a/s/benchmarks/micro/BenchmarkMicroStringConcat.st	Mon Aug 28 21:41:34 2017 +0100
+++ b/s/benchmarks/micro/BenchmarkMicroStringConcat.st	Sat Jan 25 22:15:10 2020 +0000
@@ -1,5 +1,7 @@
 "{ Package: 'jv:calipel/s/benchmarks/micro' }"
 
+"{ NameSpace: Smalltalk }"
+
 Object subclass:#BenchmarkMicroStringConcat
 	instanceVariableNames:'iterations strsize str'
 	classVariableNames:''
--- a/s/benchmarks/micro/BenchmarkMicroStringConcatN.st	Mon Aug 28 21:41:34 2017 +0100
+++ b/s/benchmarks/micro/BenchmarkMicroStringConcatN.st	Sat Jan 25 22:15:10 2020 +0000
@@ -1,5 +1,7 @@
 "{ Package: 'jv:calipel/s/benchmarks/micro' }"
 
+"{ NameSpace: Smalltalk }"
+
 Object subclass:#BenchmarkMicroStringConcatN
 	instanceVariableNames:'iterations strsize str nconcats'
 	classVariableNames:''
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/s/benchmarks/micro/BenchmarkPerformEliot.st	Sat Jan 25 22:15:10 2020 +0000
@@ -0,0 +1,91 @@
+"{ Package: 'jv:calipel/s/benchmarks/micro' }"
+
+"{ NameSpace: Smalltalk }"
+
+Benchmark subclass:#BenchmarkPerformEliot
+	instanceVariableNames:'sel'
+	classVariableNames:''
+	poolDictionaries:''
+	category:'CalipeL-S-Benchmarks-Micro'
+!
+
+!BenchmarkPerformEliot class methodsFor:'documentation'!
+
+documentation
+"
+    This class implements simple perform:with: benchmark suggested by Eliot Miranda [1]
+
+    [1]: http://forum.world.st/Re-Pharo-dev-Fed-up-tt5110526.html#none
+
+    [author:]
+        Eliot Miranda
+        Jan Vrany <jan.vrany@fit.cvut.cz>
+
+    [instance variables:]
+
+    [class variables:]
+
+    [see also:]
+
+
+"
+! !
+
+!BenchmarkPerformEliot methodsFor:'benchmarks'!
+
+benchFibBase
+    <benchmark>
+
+    self benchFibBase: 42
+
+    "Created: / 25-01-2020 / 22:06:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+benchFibBase: n
+        ^n < 2
+                ifTrue: [1] 
+                ifFalse: [(self benchFibBase: n-1)  + (self benchFibBase: n-2) + 1]
+
+    "Created: / 25-01-2020 / 22:05:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+benchFibPerform
+    <benchmark>
+
+    self benchFibPerform: 42
+
+    "Created: / 25-01-2020 / 22:07:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+benchFibPerform2
+    <benchmark>
+
+    sel := #benchFibPerform2:.
+    self benchFibPerform2: 42
+
+    "Created: / 26-01-2020 / 09:59:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+benchFibPerform2: n
+        ^n < 2
+                ifTrue: [1] 
+                ifFalse: [(self perform: sel with: n-1)  + (self perform: sel with: n-2) + 1]
+
+    "Created: / 26-01-2020 / 10:00:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+benchFibPerform: n
+        ^n < 2
+                ifTrue: [1] 
+                ifFalse: [(self perform: #benchFibPerform: with: n-1)  + (self perform: #benchFibPerform: with: n-2) + 1]
+
+    "Created: / 25-01-2020 / 22:06:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!BenchmarkPerformEliot class methodsFor:'documentation'!
+
+version_HG
+
+    ^ '$Changeset: <not expanded> $'
+! !
+
--- a/s/benchmarks/micro/BenchmarkSemaphore.st	Mon Aug 28 21:41:34 2017 +0100
+++ b/s/benchmarks/micro/BenchmarkSemaphore.st	Sat Jan 25 22:15:10 2020 +0000
@@ -9,6 +9,7 @@
 	category:'CalipeL-S-Benchmarks-Micro'
 !
 
+
 !BenchmarkSemaphore methodsFor:'running'!
 
 setUp
@@ -19,3 +20,10 @@
     "Modified: / 28-08-2017 / 21:27:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!BenchmarkSemaphore class methodsFor:'documentation'!
+
+version_HG
+
+    ^ '$Changeset: <not expanded> $'
+! !
+
--- a/s/benchmarks/micro/Make.proto	Mon Aug 28 21:41:34 2017 +0100
+++ b/s/benchmarks/micro/Make.proto	Sat Jan 25 22:15:10 2020 +0000
@@ -126,6 +126,7 @@
 $(OUTDIR)BenchmarkMicroStringConcat.$(O) BenchmarkMicroStringConcat.$(C) BenchmarkMicroStringConcat.$(H): BenchmarkMicroStringConcat.st $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
 $(OUTDIR)BenchmarkMicroStringConcatN.$(O) BenchmarkMicroStringConcatN.$(C) BenchmarkMicroStringConcatN.$(H): BenchmarkMicroStringConcatN.st $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
 $(OUTDIR)BenchmarkPerform.$(O) BenchmarkPerform.$(C) BenchmarkPerform.$(H): BenchmarkPerform.st $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
+$(OUTDIR)BenchmarkPerformEliot.$(O) BenchmarkPerformEliot.$(C) BenchmarkPerformEliot.$(H): BenchmarkPerformEliot.st $(INCLUDE_TOP)/jv/calipel/s/Benchmark.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
 $(OUTDIR)jv_calipel_s_benchmarks_micro.$(O) jv_calipel_s_benchmarks_micro.$(C) jv_calipel_s_benchmarks_micro.$(H): jv_calipel_s_benchmarks_micro.st $(INCLUDE_TOP)/stx/libbasic/LibraryDefinition.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(INCLUDE_TOP)/stx/libbasic/ProjectDefinition.$(H) $(STCHDR)
 $(OUTDIR)BenchmarkRecursionLock.$(O) BenchmarkRecursionLock.$(C) BenchmarkRecursionLock.$(H): BenchmarkRecursionLock.st $(INCLUDE_TOP)/jv/calipel/s/Benchmark.$(H) $(INCLUDE_TOP)/jv/calipel/s/benchmarks/micro/BenchmarkLocking.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
 $(OUTDIR)BenchmarkSemaphore.$(O) BenchmarkSemaphore.$(C) BenchmarkSemaphore.$(H): BenchmarkSemaphore.st $(INCLUDE_TOP)/jv/calipel/s/Benchmark.$(H) $(INCLUDE_TOP)/jv/calipel/s/benchmarks/micro/BenchmarkLocking.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
--- a/s/benchmarks/micro/Make.spec	Mon Aug 28 21:41:34 2017 +0100
+++ b/s/benchmarks/micro/Make.spec	Sat Jan 25 22:15:10 2020 +0000
@@ -55,6 +55,7 @@
 	BenchmarkMicroStringConcat \
 	BenchmarkMicroStringConcatN \
 	BenchmarkPerform \
+	BenchmarkPerformEliot \
 	jv_calipel_s_benchmarks_micro \
 	BenchmarkRecursionLock \
 	BenchmarkSemaphore \
@@ -67,6 +68,7 @@
     $(OUTDIR)BenchmarkMicroStringConcat.$(O) \
     $(OUTDIR)BenchmarkMicroStringConcatN.$(O) \
     $(OUTDIR)BenchmarkPerform.$(O) \
+    $(OUTDIR)BenchmarkPerformEliot.$(O) \
     $(OUTDIR)jv_calipel_s_benchmarks_micro.$(O) \
     $(OUTDIR)BenchmarkRecursionLock.$(O) \
     $(OUTDIR)BenchmarkSemaphore.$(O) \
--- a/s/benchmarks/micro/abbrev.stc	Mon Aug 28 21:41:34 2017 +0100
+++ b/s/benchmarks/micro/abbrev.stc	Sat Jan 25 22:15:10 2020 +0000
@@ -5,6 +5,7 @@
 BenchmarkMicroStringConcat BenchmarkMicroStringConcat jv:calipel/s/benchmarks/micro 'CalipeL-S-Benchmarks-Micro' 0
 BenchmarkMicroStringConcatN BenchmarkMicroStringConcatN jv:calipel/s/benchmarks/micro 'CalipeL-S-Benchmarks-Micro' 0
 BenchmarkPerform BenchmarkPerform jv:calipel/s/benchmarks/micro 'CalipeL-S-Benchmarks-Micro' 0
+BenchmarkPerformEliot BenchmarkPerformEliot jv:calipel/s/benchmarks/micro 'CalipeL-S-Benchmarks-Micro' 0
 jv_calipel_s_benchmarks_micro jv_calipel_s_benchmarks_micro jv:calipel/s/benchmarks/micro '* Projects & Packages *' 3
 BenchmarkRecursionLock BenchmarkRecursionLock jv:calipel/s/benchmarks/micro 'CalipeL-S-Benchmarks-Micro' 0
 BenchmarkSemaphore BenchmarkSemaphore jv:calipel/s/benchmarks/micro 'CalipeL-S-Benchmarks-Micro' 0
--- a/s/benchmarks/micro/bc.mak	Mon Aug 28 21:41:34 2017 +0100
+++ b/s/benchmarks/micro/bc.mak	Sat Jan 25 22:15:10 2020 +0000
@@ -60,7 +60,7 @@
 
 
 
-test: $(TOP)\goodies\builder\reports\NUL
+test: $(TOP)\goodies\builder\reports
 	pushd $(TOP)\goodies\builder\reports & $(MAKE_BAT)
 	$(TOP)\goodies\builder\reports\report-runner.bat -D . -r Builder::TestReport -p $(PACKAGE)
         
@@ -73,6 +73,7 @@
 $(OUTDIR)BenchmarkMicroStringConcat.$(O) BenchmarkMicroStringConcat.$(C) BenchmarkMicroStringConcat.$(H): BenchmarkMicroStringConcat.st $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
 $(OUTDIR)BenchmarkMicroStringConcatN.$(O) BenchmarkMicroStringConcatN.$(C) BenchmarkMicroStringConcatN.$(H): BenchmarkMicroStringConcatN.st $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
 $(OUTDIR)BenchmarkPerform.$(O) BenchmarkPerform.$(C) BenchmarkPerform.$(H): BenchmarkPerform.st $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
+$(OUTDIR)BenchmarkPerformEliot.$(O) BenchmarkPerformEliot.$(C) BenchmarkPerformEliot.$(H): BenchmarkPerformEliot.st $(INCLUDE_TOP)\jv\calipel\s\Benchmark.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
 $(OUTDIR)jv_calipel_s_benchmarks_micro.$(O) jv_calipel_s_benchmarks_micro.$(C) jv_calipel_s_benchmarks_micro.$(H): jv_calipel_s_benchmarks_micro.st $(INCLUDE_TOP)\stx\libbasic\LibraryDefinition.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(INCLUDE_TOP)\stx\libbasic\ProjectDefinition.$(H) $(STCHDR)
 $(OUTDIR)BenchmarkRecursionLock.$(O) BenchmarkRecursionLock.$(C) BenchmarkRecursionLock.$(H): BenchmarkRecursionLock.st $(INCLUDE_TOP)\jv\calipel\s\Benchmark.$(H) $(INCLUDE_TOP)\jv\calipel\s\benchmarks\micro\BenchmarkLocking.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
 $(OUTDIR)BenchmarkSemaphore.$(O) BenchmarkSemaphore.$(C) BenchmarkSemaphore.$(H): BenchmarkSemaphore.st $(INCLUDE_TOP)\jv\calipel\s\Benchmark.$(H) $(INCLUDE_TOP)\jv\calipel\s\benchmarks\micro\BenchmarkLocking.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
--- a/s/benchmarks/micro/jv_calipel_s_benchmarks_micro.st	Mon Aug 28 21:41:34 2017 +0100
+++ b/s/benchmarks/micro/jv_calipel_s_benchmarks_micro.st	Sat Jan 25 22:15:10 2020 +0000
@@ -47,7 +47,7 @@
      Please also take a look at the #mandatoryPreRequisites method"
 
     ^ #(
-        #'stx:libbasic2'    "Random - referenced by BenchmarkPerform class>>initialize"
+        #'stx:libbasic2'    "Monitor - referenced by BenchmarkRecursionLock>>setUp"
     )
 !
 
@@ -87,6 +87,7 @@
         BenchmarkMicroStringConcat
         BenchmarkMicroStringConcatN
         BenchmarkPerform
+        BenchmarkPerformEliot
         #'jv_calipel_s_benchmarks_micro'
         BenchmarkRecursionLock
         BenchmarkSemaphore
--- a/s/benchmarks/micro/libInit.cc	Mon Aug 28 21:41:34 2017 +0100
+++ b/s/benchmarks/micro/libInit.cc	Sat Jan 25 22:15:10 2020 +0000
@@ -20,6 +20,7 @@
 extern void _BenchmarkMicroStringConcat_Init(int pass, struct __vmData__ *__pRT__, OBJ snd);
 extern void _BenchmarkMicroStringConcatN_Init(int pass, struct __vmData__ *__pRT__, OBJ snd);
 extern void _BenchmarkPerform_Init(int pass, struct __vmData__ *__pRT__, OBJ snd);
+extern void _BenchmarkPerformEliot_Init(int pass, struct __vmData__ *__pRT__, OBJ snd);
 extern void _jv_137calipel_137s_137benchmarks_137micro_Init(int pass, struct __vmData__ *__pRT__, OBJ snd);
 extern void _BenchmarkRecursionLock_Init(int pass, struct __vmData__ *__pRT__, OBJ snd);
 extern void _BenchmarkSemaphore_Init(int pass, struct __vmData__ *__pRT__, OBJ snd);
@@ -41,6 +42,7 @@
     _BenchmarkMicroStringConcat_Init(pass,__pRT__,snd);
     _BenchmarkMicroStringConcatN_Init(pass,__pRT__,snd);
     _BenchmarkPerform_Init(pass,__pRT__,snd);
+    _BenchmarkPerformEliot_Init(pass,__pRT__,snd);
     _jv_137calipel_137s_137benchmarks_137micro_Init(pass,__pRT__,snd);
     _BenchmarkRecursionLock_Init(pass,__pRT__,snd);
     _BenchmarkSemaphore_Init(pass,__pRT__,snd);