#DOCUMENTATION by cg
class: CRC32Stream class
added: #newCastagnoli
comment/format in:
#documentation
#examples
#new
changed:
#newCCITT
#newCrc32c
--- a/CRC32Stream.st Sun Mar 17 15:09:28 2019 +0100
+++ b/CRC32Stream.st Sun Mar 17 15:09:39 2019 +0100
@@ -57,11 +57,11 @@
Only use CRC to protect against communication errors;
do NOT use CRC for cryptography - use SHA1Stream or MD5Stream instead.
- Notice that this CRC is also used with PNG images - therefore, its performance
- directly affects png image processing.
+ Notice that this CRC is also used with PNG images;
+ therefore, its performance directly affects png image processing (png write speed).
throughput:
- 220 Mb/s on MacBook Pro (2.6Ghz I7)
+ 235 Mb/s on MacBook Pro (2.6Ghz I7)
157000 Kb/s on a 2.5Ghz 64X2 Athlon 4800+ (64bit)
150000 Kb/s on 2Ghz Duo
@@ -117,7 +117,7 @@
|hashStream n t|
hashStream := CRC32Stream new.
- n := 1000000.
+ n := 2000000.
t := Time millisecondsToRun:[
n timesRepeat:[
hashStream nextPutAll:'12345678901234567890123456789012345678901234567890'.
@@ -192,14 +192,13 @@
!
new
- "return an instance of the ITU-T CRC-32
- x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1"
+ "return an instance of the ITU-T CRC-32"
- "/ 16r4C11DB7 bitReversed32 -> 16rEDB88320
^ self newCCITT
"Created: / 16-03-2019 / 21:09:19 / Claus Gittinger"
"Modified: / 16-03-2019 / 23:29:45 / Claus Gittinger"
+ "Modified (comment): / 17-03-2019 / 14:34:47 / Claus Gittinger"
!
newCCITT
@@ -207,18 +206,41 @@
x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1"
"/ 16r4C11DB7 bitReversed32 -> 16rEDB88320
- ^ self generatorPolynom:16rEDB88320 initValue:16rFFFFFFFF xorOut:16rFFFFFFFF
+ ^ self generatorPolynomMSB:16r4C11DB7
+ initValue:16rFFFFFFFF xorOut:16rFFFFFFFF
"Created: / 16-03-2019 / 23:29:39 / Claus Gittinger"
+ "Modified: / 17-03-2019 / 14:07:36 / Claus Gittinger"
!
-newCrc32c
+newCastagnoli
"return an instance of the Castagnoli CRC-32
x32 + x28 + x27 + x26 + x25 + x23 + x22 + x20 + x19 + x18 + x14 + x13 + x11 + x10 + x9 + x8 + x6 + 1
(used in iSCSI & SCTP, G.hn payload, SSE4.2)"
"/ 16r1edc6f41 bitReversed32 -> 16r82F63B78
- ^ self generatorPolynom:16r82F63B78 initValue:16rFFFFFFFF xorOut:16rFFFFFFFF
+ ^ self generatorPolynomMSB:16r1edc6f41
+ initValue:16rFFFFFFFF xorOut:16rFFFFFFFF
+
+ "
+ Castagnoli crc:
+ self assert:((self newCrc32c)
+ nextPut:'123456789';
+ hashValue) = 3808858755. '16rE3069283'
+
+ default crc:
+ self assert:((self new)
+ nextPut:'123456789';
+ hashValue) = 3421780262. '16rCBF43926'
+ "
+
+ "Created: / 17-03-2019 / 14:33:54 / Claus Gittinger"
+!
+
+newCrc32c
+ "return an instance of the Castagnoli CRC-32"
+
+ ^ self newCastagnoli
"
Castagnoli crc:
@@ -233,7 +255,7 @@
"
"Modified (comment): / 17-05-2012 / 12:48:53 / cg"
- "Modified: / 16-03-2019 / 21:21:07 / Claus Gittinger"
+ "Modified: / 17-03-2019 / 14:34:26 / Claus Gittinger"
! !
!CRC32Stream methodsFor:'initialization'!