Block.st
changeset 19795 e40276e51301
parent 19450 0d87809d2fb4
child 19812 0866264d6eed
child 20144 edb8a61ce8eb
--- a/Block.st	Thu May 12 17:28:58 2016 +0200
+++ b/Block.st	Thu May 12 17:29:58 2016 +0200
@@ -848,31 +848,38 @@
 benchmark:anInfoString
     "evaluate myseld and show the timing info on Transcript"
 
-    |startTime endTime micros millis|
-
+    |startTime endTime overhead micros millis|
+
+    startTime := OperatingSystem getMicrosecondTime.
+    [123] value.
+    endTime := OperatingSystem getMicrosecondTime.
+    overhead := endTime - startTime.
+    
     startTime := OperatingSystem getMicrosecondTime.
     self value.
     endTime := OperatingSystem getMicrosecondTime.
 
-    micros := endTime - startTime.
+    micros := (endTime - startTime - overhead) max:0.
 
     Transcript show:anInfoString.
     micros < 1000 ifTrue:[
-	Transcript show:micros; show:' µs'.
+        "/ too stupid: many fonts do not have a mu,
+        "/ so I output it as us here.
+        Transcript show:micros; show:' us'.
     ] ifFalse:[
-	micros < 100000 ifTrue:[
-	    millis := (micros / 1000.0) asFixedPointRoundedToScale:2.
-	    Transcript show:millis; show:' ms'.
-	] ifFalse:[
-	    millis := micros // 1000.
-	    Transcript show:(TimeDuration milliseconds:millis).
-	].
+        micros < 100000 ifTrue:[
+            millis := (micros / 1000.0) asFixedPointRoundedToScale:2.
+            Transcript show:millis; show:' ms'.
+        ] ifFalse:[
+            millis := micros // 1000.
+            Transcript show:(TimeDuration milliseconds:millis).
+        ].
     ].
     Transcript cr.
 
     "
-	[10 factorial] benchmark:'10 factorial:'
-	[100 factorial] benchmark:'100 factorial:'
+        [10 factorial] benchmark:'10 factorial:'
+        [100 factorial] benchmark:'100 factorial:'
     "
 ! !