RegressionTests__CryptTests.st
changeset 2135 e15ffe219b3f
parent 2122 a9c72db987e7
child 2138 373c662a4638
--- a/RegressionTests__CryptTests.st	Sat Mar 23 14:41:23 2019 +0100
+++ b/RegressionTests__CryptTests.st	Sat Mar 23 14:53:01 2019 +0100
@@ -1087,6 +1087,51 @@
     "
 
     "Created: / 22-03-2019 / 12:45:45 / Claus Gittinger"
+!
+
+test99_speed
+    |oneTest speedTest|
+
+    self skipIf:true description:'speedtest; not part of automated test suite'.
+
+    oneTest := [:name :hashStream :n :s |
+        |l t nMb|
+
+        l := s size.
+        t := Time millisecondsToRun:[
+                n timesRepeat:[
+                        hashStream nextPutAll:s
+                ].
+             ].
+        t := (t / 1000) asFloat.
+        nMb := n*l/1024/1024.
+        Transcript showCR:'%1: %2 (chunk size %3)' with:name with:(hashStream hashValue hexPrintString) with:l.
+        Transcript showCR:'  %1 seconds for %2 Mb' with:t with:(nMb asFixedPoint:2).
+        Transcript showCR:'  %1 Mb/s' with:((nMb / t) asFixedPoint:2).
+    ].
+
+    speedTest := [:name :hashStreamMaker |
+        Transcript showCR:'-----------------------'.
+        oneTest 
+            value:name value:(hashStreamMaker value) value:2000000
+            value:'1234567890'.
+        oneTest
+            value:name value:(hashStreamMaker value) value:2000000
+            value:'12345678901234567890123456789012345678901234567890'.
+        oneTest
+            value:name value:(hashStreamMaker value) value:200000
+            value:('12345678901234567890123456789012345678901234567890' ,* 20).
+        oneTest
+            value:name value:(hashStreamMaker value) value:20000
+            value:('12345678901234567890123456789012345678901234567890' ,* 1000).
+    ].
+
+    speedTest 
+        value:'md5' value:[MD5Stream new].
+    speedTest 
+        value:'sha1' value:[SHA1Stream new].
+
+    "Created: / 23-03-2019 / 14:47:01 / Claus Gittinger"
 ! !
 
 !CryptTests class methodsFor:'documentation'!