digest-crc 0.4.2 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +5 -0
- data/.travis.yml +8 -0
- data/.yardopts +0 -1
- data/ChangeLog.md +137 -1
- data/Gemfile +2 -1
- data/README.md +122 -2
- data/Rakefile +26 -3
- data/benchmarks.rb +34 -21
- data/digest-crc.gemspec +2 -1
- data/ext/digest/Rakefile +51 -0
- data/ext/digest/compat/ruby.h +11 -0
- data/ext/digest/crc12_3gpp/crc12_3gpp.c +68 -0
- data/ext/digest/crc12_3gpp/crc12_3gpp.h +11 -0
- data/ext/digest/crc12_3gpp/crc12_3gpp_ext.c +27 -0
- data/ext/digest/crc12_3gpp/extconf.rb +7 -0
- data/ext/digest/crc15/crc15.c +54 -0
- data/ext/digest/crc15/crc15.h +11 -0
- data/ext/digest/crc15/crc15_ext.c +28 -0
- data/ext/digest/crc15/extconf.rb +7 -0
- data/ext/digest/crc16/crc16.c +70 -0
- data/ext/digest/crc16/crc16.h +11 -0
- data/ext/digest/crc16/crc16_ext.c +28 -0
- data/ext/digest/crc16/extconf.rb +7 -0
- data/ext/digest/crc16_ccitt/crc16_ccitt.c +70 -0
- data/ext/digest/crc16_ccitt/crc16_ccitt.h +8 -0
- data/ext/digest/crc16_ccitt/crc16_ccitt_ext.c +28 -0
- data/ext/digest/crc16_ccitt/extconf.rb +7 -0
- data/ext/digest/crc16_dnp/crc16_dnp.c +54 -0
- data/ext/digest/crc16_dnp/crc16_dnp.h +8 -0
- data/ext/digest/crc16_dnp/crc16_dnp_ext.c +28 -0
- data/ext/digest/crc16_dnp/extconf.rb +7 -0
- data/ext/digest/crc16_genibus/crc16_genibus.c +70 -0
- data/ext/digest/crc16_genibus/crc16_genibus.h +8 -0
- data/ext/digest/crc16_genibus/crc16_genibus_ext.c +28 -0
- data/ext/digest/crc16_genibus/extconf.rb +7 -0
- data/ext/digest/crc16_kermit/crc16_kermit.c +70 -0
- data/ext/digest/crc16_kermit/crc16_kermit.h +8 -0
- data/ext/digest/crc16_kermit/crc16_kermit_ext.c +28 -0
- data/ext/digest/crc16_kermit/extconf.rb +7 -0
- data/ext/digest/crc16_modbus/crc16_modbus.c +70 -0
- data/ext/digest/crc16_modbus/crc16_modbus.h +8 -0
- data/ext/digest/crc16_modbus/crc16_modbus_ext.c +28 -0
- data/ext/digest/crc16_modbus/extconf.rb +7 -0
- data/ext/digest/crc16_usb/crc16_usb.c +70 -0
- data/ext/digest/crc16_usb/crc16_usb.h +8 -0
- data/ext/digest/crc16_usb/crc16_usb_ext.c +28 -0
- data/ext/digest/crc16_usb/extconf.rb +7 -0
- data/ext/digest/crc16_x_25/crc16_x_25.c +70 -0
- data/ext/digest/crc16_x_25/crc16_x_25.h +8 -0
- data/ext/digest/crc16_x_25/crc16_x_25_ext.c +28 -0
- data/ext/digest/crc16_x_25/extconf.rb +7 -0
- data/ext/digest/crc16_xmodem/crc16_xmodem.c +70 -0
- data/ext/digest/crc16_xmodem/crc16_xmodem.h +8 -0
- data/ext/digest/crc16_xmodem/crc16_xmodem_ext.c +28 -0
- data/ext/digest/crc16_xmodem/extconf.rb +7 -0
- data/ext/digest/crc16_zmodem/crc16_zmodem.c +70 -0
- data/ext/digest/crc16_zmodem/crc16_zmodem.h +8 -0
- data/ext/digest/crc16_zmodem/crc16_zmodem_ext.c +28 -0
- data/ext/digest/crc16_zmodem/extconf.rb +7 -0
- data/ext/digest/crc24/crc24.c +70 -0
- data/ext/digest/crc24/crc24.h +11 -0
- data/ext/digest/crc24/crc24_ext.c +27 -0
- data/ext/digest/crc24/extconf.rb +7 -0
- data/ext/digest/crc32/crc32.c +69 -0
- data/ext/digest/crc32/crc32.h +11 -0
- data/ext/digest/crc32/crc32_ext.c +27 -0
- data/ext/digest/crc32/extconf.rb +7 -0
- data/ext/digest/crc32_bzip2/crc32_bzip2.c +70 -0
- data/ext/digest/crc32_bzip2/crc32_bzip2.h +8 -0
- data/ext/digest/crc32_bzip2/crc32_bzip2_ext.c +27 -0
- data/ext/digest/crc32_bzip2/extconf.rb +7 -0
- data/ext/digest/crc32_jam/crc32_jam.c +70 -0
- data/ext/digest/crc32_jam/crc32_jam.h +8 -0
- data/ext/digest/crc32_jam/crc32_jam_ext.c +27 -0
- data/ext/digest/crc32_jam/extconf.rb +7 -0
- data/ext/digest/crc32_mpeg/crc32_mpeg.c +70 -0
- data/ext/digest/crc32_mpeg/crc32_mpeg.h +8 -0
- data/ext/digest/crc32_mpeg/crc32_mpeg_ext.c +27 -0
- data/ext/digest/crc32_mpeg/extconf.rb +7 -0
- data/ext/digest/crc32_posix/crc32_posix.c +70 -0
- data/ext/digest/crc32_posix/crc32_posix.h +8 -0
- data/ext/digest/crc32_posix/crc32_posix_ext.c +27 -0
- data/ext/digest/crc32_posix/extconf.rb +7 -0
- data/ext/digest/crc32_xfer/crc32_xfer.c +70 -0
- data/ext/digest/crc32_xfer/crc32_xfer.h +8 -0
- data/ext/digest/crc32_xfer/crc32_xfer_ext.c +27 -0
- data/ext/digest/crc32_xfer/extconf.rb +7 -0
- data/ext/digest/crc32c/crc32c.c +70 -0
- data/ext/digest/crc32c/crc32c.h +8 -0
- data/ext/digest/crc32c/crc32c_ext.c +27 -0
- data/ext/digest/crc32c/extconf.rb +7 -0
- data/ext/digest/crc5/crc5.c +54 -0
- data/ext/digest/crc5/crc5.h +11 -0
- data/ext/digest/crc5/crc5_ext.c +27 -0
- data/ext/digest/crc5/extconf.rb +7 -0
- data/ext/digest/crc64/crc64.c +102 -0
- data/ext/digest/crc64/crc64.h +11 -0
- data/ext/digest/crc64/crc64_ext.c +27 -0
- data/ext/digest/crc64/extconf.rb +7 -0
- data/ext/digest/crc64_jones/crc64_jones.c +102 -0
- data/ext/digest/crc64_jones/crc64_jones.h +8 -0
- data/ext/digest/crc64_jones/crc64_jones_ext.c +27 -0
- data/ext/digest/crc64_jones/extconf.rb +7 -0
- data/ext/digest/crc64_xz/crc64_xz.c +102 -0
- data/ext/digest/crc64_xz/crc64_xz.h +8 -0
- data/ext/digest/crc64_xz/crc64_xz_ext.c +27 -0
- data/ext/digest/crc64_xz/extconf.rb +7 -0
- data/ext/digest/crc8/crc8.c +54 -0
- data/ext/digest/crc8/crc8.h +11 -0
- data/ext/digest/crc8/crc8_ext.c +27 -0
- data/ext/digest/crc8/extconf.rb +7 -0
- data/ext/digest/crc8_1wire/crc8_1wire.c +54 -0
- data/ext/digest/crc8_1wire/crc8_1wire.h +8 -0
- data/ext/digest/crc8_1wire/crc8_1wire_ext.c +27 -0
- data/ext/digest/crc8_1wire/extconf.rb +7 -0
- data/gemspec.yml +15 -2
- data/lib/digest/crc15.rb +70 -0
- data/lib/digest/crc16.rb +4 -0
- data/lib/digest/crc16_ccitt.rb +4 -0
- data/lib/digest/crc16_dnp.rb +4 -0
- data/lib/digest/crc16_genibus.rb +72 -0
- data/lib/digest/crc16_kermit.rb +66 -0
- data/lib/digest/crc16_modbus.rb +4 -0
- data/lib/digest/crc16_qt.rb +3 -60
- data/lib/digest/crc16_usb.rb +4 -0
- data/lib/digest/crc16_x_25.rb +56 -0
- data/lib/digest/crc16_xmodem.rb +4 -0
- data/lib/digest/crc16_zmodem.rb +4 -0
- data/lib/digest/crc24.rb +4 -0
- data/lib/digest/crc32.rb +5 -1
- data/lib/digest/crc32_bzip2.rb +64 -0
- data/lib/digest/crc32_jam.rb +16 -0
- data/lib/digest/crc32_mpeg.rb +8 -1
- data/lib/digest/crc32_posix.rb +65 -0
- data/lib/digest/crc32_xfer.rb +68 -0
- data/lib/digest/crc32c.rb +4 -0
- data/lib/digest/crc5.rb +4 -0
- data/lib/digest/crc64.rb +4 -0
- data/lib/digest/crc64_jones.rb +88 -0
- data/lib/digest/crc64_xz.rb +90 -0
- data/lib/digest/crc8.rb +4 -0
- data/lib/digest/crc8_1wire.rb +8 -1
- data/spec/crc15_spec.rb +10 -0
- data/spec/crc16_genibus_spec.rb +10 -0
- data/spec/crc16_kermit_spec.rb +10 -0
- data/spec/crc16_qt_spec.rb +5 -5
- data/spec/crc16_x_25_spec.rb +10 -0
- data/spec/crc32_bzip2_spec.rb +10 -0
- data/spec/crc32_jam_spec.rb +10 -0
- data/spec/crc32_mpeg_spec.rb +7 -1
- data/spec/crc32_posix_spec.rb +10 -0
- data/spec/crc32_xfer_spec.rb +10 -0
- data/spec/crc64_jones_spec.rb +10 -0
- data/spec/crc64_xz_spec.rb +10 -0
- data/spec/crc8_1wire_spec.rb +7 -1
- metadata +152 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9f6be5490751ab763c1fdd99f95a2e4ae0a22a073969623f14170159cb55c5b0
|
4
|
+
data.tar.gz: 7f152d312932b784ce074ce9d463bf07dd2bccf5035d9b1bc98dd8c804daa377
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0e9e53d3fc14577e50276ea0f13b663bf62fcafbc2a063491e076bdec99d467f0c57ad0d0cb5b794af1dbadc6794db4070cb6d956b13f4525c5c30af3dea618b
|
7
|
+
data.tar.gz: '07198de582c8e350def1763a6c2593ad8a42065c675826c278e3326e81d1a1960b613879a7df017727e12cdc4a4ffc36c15350108a3f6d87076e1f28e4d81afe'
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -2,15 +2,23 @@
|
|
2
2
|
before_install:
|
3
3
|
- gem update --system
|
4
4
|
- gem install bundler -v "~> 2.0"
|
5
|
+
|
5
6
|
language: ruby
|
6
7
|
sudo: false
|
7
8
|
cache:
|
8
9
|
- bundler
|
10
|
+
|
9
11
|
rvm:
|
10
12
|
- 2.5
|
11
13
|
- 2.6
|
14
|
+
- 2.7
|
12
15
|
- jruby
|
16
|
+
|
13
17
|
matrix:
|
18
|
+
include:
|
19
|
+
- os: linux
|
20
|
+
- os: osx
|
14
21
|
allow_failures:
|
15
22
|
- rvm: jruby
|
23
|
+
|
16
24
|
script: bundle exec rake spec
|
data/.yardopts
CHANGED
data/ChangeLog.md
CHANGED
@@ -1,3 +1,140 @@
|
|
1
|
+
### 0.6.1 / 2020-07-02
|
2
|
+
|
3
|
+
* Fix installation issues under bundler by adding rake as an explicit dependency
|
4
|
+
(@rogerluan).
|
5
|
+
|
6
|
+
### 0.6.0 / 2020-07-01
|
7
|
+
|
8
|
+
* Implement _optional_ C extensions for all CRC algorithms, resulting in an
|
9
|
+
average performance improvement of ~40x. Note, if for whatever reason the
|
10
|
+
C extensions cannot be compiled, they will be skipped and the pure-Ruby
|
11
|
+
CRC algorithms will be used instead. If the C extensions were successfully
|
12
|
+
compiled, then they will be loaded and override the pure-Ruby CRC methods with
|
13
|
+
the C equivalents.
|
14
|
+
* Alias {Digest::CRC16QT} to {Digest::CRC16X25}, since they are effectively the same (@dearblue).
|
15
|
+
* Fix {Digest::CRC32::WIDTH} (@dearblue).
|
16
|
+
|
17
|
+
#### pure-Ruby (ruby 2.7.1)
|
18
|
+
|
19
|
+
Loading Digest::CRC classes ...
|
20
|
+
Generating 1000 8Kb lengthed strings ...
|
21
|
+
Benchmarking Digest::CRC classes ...
|
22
|
+
user system total real
|
23
|
+
Digest::CRC1#update 0.412953 0.000000 0.412953 ( 0.414688)
|
24
|
+
Digest::CRC5#update 1.116375 0.000003 1.116378 ( 1.120741)
|
25
|
+
Digest::CRC8#update 0.994263 0.000013 0.994276 ( 1.001079)
|
26
|
+
Digest::CRC8_1Wire#update 0.974115 0.000004 0.974119 ( 0.978186)
|
27
|
+
Digest::CRC15#update 1.139402 0.000927 1.140329 ( 1.146608)
|
28
|
+
Digest::CRC16#update 0.967836 0.000000 0.967836 ( 0.971792)
|
29
|
+
Digest::CRC16CCITT#update 1.118851 0.000000 1.118851 ( 1.123217)
|
30
|
+
Digest::CRC16DNP#update 0.922211 0.000000 0.922211 ( 0.925739)
|
31
|
+
Digest::CRC16Genibus#update 1.120580 0.000000 1.120580 ( 1.124771)
|
32
|
+
Digest::CRC16Modbus#update 0.955612 0.000000 0.955612 ( 0.959463)
|
33
|
+
Digest::CRC16QT#update 8.153403 0.000012 8.153415 ( 8.189977)
|
34
|
+
Digest::CRC16USB#update 0.952557 0.000000 0.952557 ( 0.956145)
|
35
|
+
Digest::CRC16X25#update 0.962295 0.000000 0.962295 ( 0.970401)
|
36
|
+
Digest::CRC16XModem#update 1.120531 0.000000 1.120531 ( 1.124494)
|
37
|
+
Digest::CRC16ZModem#update 1.124226 0.000000 1.124226 ( 1.128632)
|
38
|
+
Digest::CRC24#update 1.126317 0.000000 1.126317 ( 1.130794)
|
39
|
+
Digest::CRC32#update 0.960015 0.000000 0.960015 ( 0.964803)
|
40
|
+
Digest::CRC32BZip2#update 1.128626 0.000000 1.128626 ( 1.133641)
|
41
|
+
Digest::CRC32c#update 0.964047 0.000000 0.964047 ( 0.967456)
|
42
|
+
Digest::CRC32Jam#update 0.959141 0.000972 0.960113 ( 0.967444)
|
43
|
+
Digest::CRC32MPEG#update 1.131119 0.000002 1.131121 ( 1.137440)
|
44
|
+
Digest::CRC32POSIX#update 1.126019 0.000000 1.126019 ( 1.130549)
|
45
|
+
Digest::CRC32XFER#update 1.116598 0.000000 1.116598 ( 1.120595)
|
46
|
+
Digest::CRC64#update 2.665880 0.000928 2.666808 ( 2.680942)
|
47
|
+
Digest::CRC64Jones#update 2.678003 0.000000 2.678003 ( 2.691390)
|
48
|
+
Digest::CRC64XZ#update 2.671395 0.000000 2.671395 ( 2.682684)
|
49
|
+
|
50
|
+
#### pure-Ruby (jruby 9.2.11.1)
|
51
|
+
|
52
|
+
Loading Digest::CRC classes ...
|
53
|
+
Generating 1000 8Kb lengthed strings ...
|
54
|
+
Benchmarking Digest::CRC classes ...
|
55
|
+
user system total real
|
56
|
+
Digest::CRC1#update 0.700000 0.070000 0.770000 ( 0.436112)
|
57
|
+
Digest::CRC5#update 1.930000 0.050000 1.980000 ( 1.084749)
|
58
|
+
Digest::CRC8#update 1.510000 0.060000 1.570000 ( 0.979123)
|
59
|
+
Digest::CRC8_1Wire#update 0.730000 0.030000 0.760000 ( 0.761309)
|
60
|
+
Digest::CRC15#update 1.760000 0.080000 1.840000 ( 1.061413)
|
61
|
+
Digest::CRC16#update 1.560000 0.030000 1.590000 ( 0.951273)
|
62
|
+
Digest::CRC16CCITT#update 1.700000 0.010000 1.710000 ( 1.046854)
|
63
|
+
Digest::CRC16DNP#update 1.490000 0.000000 1.490000 ( 0.902434)
|
64
|
+
Digest::CRC16Genibus#update 1.820000 0.020000 1.840000 ( 1.030269)
|
65
|
+
Digest::CRC16Modbus#update 0.740000 0.010000 0.750000 ( 0.738604)
|
66
|
+
Digest::CRC16QT#update 7.280000 0.040000 7.320000 ( 6.399987)
|
67
|
+
Digest::CRC16USB#update 0.930000 0.000000 0.930000 ( 0.801541)
|
68
|
+
Digest::CRC16X25#update 0.870000 0.000000 0.870000 ( 0.805130)
|
69
|
+
Digest::CRC16XModem#update 1.320000 0.010000 1.330000 ( 0.968956)
|
70
|
+
Digest::CRC16ZModem#update 1.300000 0.010000 1.310000 ( 0.928303)
|
71
|
+
Digest::CRC24#update 1.550000 0.020000 1.570000 ( 1.024450)
|
72
|
+
Digest::CRC32#update 1.260000 0.000000 1.260000 ( 0.913814)
|
73
|
+
Digest::CRC32BZip2#update 1.210000 0.010000 1.220000 ( 0.919086)
|
74
|
+
Digest::CRC32c#update 0.770000 0.010000 0.780000 ( 0.761726)
|
75
|
+
Digest::CRC32Jam#update 0.930000 0.000000 0.930000 ( 0.800468)
|
76
|
+
Digest::CRC32MPEG#update 1.240000 0.010000 1.250000 ( 0.933962)
|
77
|
+
Digest::CRC32POSIX#update 1.290000 0.010000 1.300000 ( 0.925254)
|
78
|
+
Digest::CRC32XFER#update 1.270000 0.000000 1.270000 ( 0.920521)
|
79
|
+
Digest::CRC64#update 3.480000 0.020000 3.500000 ( 2.883794)
|
80
|
+
Digest::CRC64Jones#update 2.740000 0.000000 2.740000 ( 2.738251)
|
81
|
+
Digest::CRC64XZ#update 2.780000 0.010000 2.790000 ( 2.715833)
|
82
|
+
|
83
|
+
|
84
|
+
#### C extensions (ruby 2.7.1)
|
85
|
+
|
86
|
+
Loading Digest::CRC classes ...
|
87
|
+
Generating 1000 8Kb lengthed strings ...
|
88
|
+
Benchmarking Digest::CRC classes ...
|
89
|
+
user system total real
|
90
|
+
Digest::CRC1#update 0.407438 0.000000 0.407438 ( 0.410495)
|
91
|
+
Digest::CRC5#update 0.022873 0.000000 0.022873 ( 0.023796)
|
92
|
+
Digest::CRC8#update 0.020129 0.000000 0.020129 ( 0.020887)
|
93
|
+
Digest::CRC8_1Wire#update 0.020106 0.000000 0.020106 ( 0.020897)
|
94
|
+
Digest::CRC15#update 0.028765 0.000003 0.028768 ( 0.029549)
|
95
|
+
Digest::CRC16#update 0.022176 0.000856 0.023032 ( 0.023153)
|
96
|
+
Digest::CRC16CCITT#update 0.028570 0.000000 0.028570 ( 0.028691)
|
97
|
+
Digest::CRC16DNP#update 0.023240 0.000001 0.023241 ( 0.024008)
|
98
|
+
Digest::CRC16Genibus#update 0.028692 0.000000 0.028692 ( 0.029575)
|
99
|
+
Digest::CRC16Modbus#update 0.023928 0.000000 0.023928 ( 0.024859)
|
100
|
+
Digest::CRC16QT#update 7.965822 0.000968 7.966790 ( 8.001781)
|
101
|
+
Digest::CRC16USB#update 0.023448 0.000001 0.023449 ( 0.024420)
|
102
|
+
Digest::CRC16X25#update 0.023061 0.000000 0.023061 ( 0.023861)
|
103
|
+
Digest::CRC16XModem#update 0.029407 0.000000 0.029407 ( 0.030583)
|
104
|
+
Digest::CRC16ZModem#update 0.029522 0.000000 0.029522 ( 0.030438)
|
105
|
+
Digest::CRC24#update 0.029528 0.000000 0.029528 ( 0.030504)
|
106
|
+
Digest::CRC32#update 0.023306 0.000000 0.023306 ( 0.024278)
|
107
|
+
Digest::CRC32BZip2#update 0.026346 0.000000 0.026346 ( 0.027293)
|
108
|
+
Digest::CRC32c#update 0.023525 0.000000 0.023525 ( 0.024489)
|
109
|
+
Digest::CRC32Jam#update 0.023348 0.000000 0.023348 ( 0.023477)
|
110
|
+
Digest::CRC32MPEG#update 0.026287 0.000000 0.026287 ( 0.027394)
|
111
|
+
Digest::CRC32POSIX#update 0.026063 0.000000 0.026063 ( 0.026986)
|
112
|
+
Digest::CRC32XFER#update 0.026374 0.000000 0.026374 ( 0.027314)
|
113
|
+
Digest::CRC64#update 0.023523 0.000000 0.023523 ( 0.024484)
|
114
|
+
Digest::CRC64Jones#update 0.023479 0.000000 0.023479 ( 0.024432)
|
115
|
+
Digest::CRC64XZ#update 0.024146 0.000000 0.024146 ( 0.025129)
|
116
|
+
|
117
|
+
### 0.5.1 / 2020-03-03
|
118
|
+
|
119
|
+
* Fixed XOR logic in {Digest::CRC16Genibus}.
|
120
|
+
* Freeze all `TABLE` constants.
|
121
|
+
* Added missing documentation.
|
122
|
+
|
123
|
+
### 0.5.0 / 2020-03-01
|
124
|
+
|
125
|
+
* Added {Digest::CRC15}.
|
126
|
+
* Added {Digest::CRC16Genibus}.
|
127
|
+
* Added {Digest::CRC16Kermit}.
|
128
|
+
* Added {Digest::CRC16X25}.
|
129
|
+
* Added {Digest::CRC32BZip2}.
|
130
|
+
* Added {Digest::CRC32Jam}.
|
131
|
+
* Added {Digest::CRC32POSIX}.
|
132
|
+
* Added {Digest::CRC32XFER}.
|
133
|
+
* Added {Digest::CRC64Jones}.
|
134
|
+
* Added {Digest::CRC64XZ}.
|
135
|
+
* Renamed `Digest::CRC32Mpeg` to {Digest::CRC32MPEG}.
|
136
|
+
* Renamed `Digest::CRC81Wire` to {Digest::CRC8_1Wire}.
|
137
|
+
|
1
138
|
### 0.4.2 / 2020-03-01
|
2
139
|
|
3
140
|
* Corrected the logic in {Digest::CRC32#update}.
|
@@ -42,4 +179,3 @@
|
|
42
179
|
* CRC32
|
43
180
|
* CRC32 Mpeg
|
44
181
|
* CRC64
|
45
|
-
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -18,22 +18,35 @@ module.
|
|
18
18
|
* {Digest::CRC1 CRC1}
|
19
19
|
* {Digest::CRC5 CRC5}
|
20
20
|
* {Digest::CRC8 CRC8}
|
21
|
-
* {Digest::
|
21
|
+
* {Digest::CRC8_1Wire CRC8 1-Wire}
|
22
|
+
* {Digest::CRC15 CRC15}
|
22
23
|
* {Digest::CRC16 CRC16}
|
23
24
|
* {Digest::CRC16CCITT CRC16 CCITT}
|
24
25
|
* {Digest::CRC16DNP CRC16 DNP}
|
26
|
+
* {Digest::CRC16Genibus CRC16 Genibus}
|
27
|
+
* {Digest::CRC16Kermit CRC16 Kermit}
|
25
28
|
* {Digest::CRC16Modbus CRC16 Modbus}
|
26
29
|
* {Digest::CRC16USB CRC16 USB}
|
30
|
+
* {Digest::CRC16X25 CRC16 X25}
|
27
31
|
* {Digest::CRC16XModem CRC16 XModem}
|
28
32
|
* {Digest::CRC16ZModem CRC16 ZModem}
|
29
33
|
* {Digest::CRC16QT CRC16 QT}
|
30
34
|
* {Digest::CRC24 CRC24}
|
31
35
|
* {Digest::CRC32 CRC32}
|
36
|
+
* {Digest::CRC32BZip2 CRC32 BZip2}
|
32
37
|
* {Digest::CRC32c CRC32c}
|
33
|
-
* {Digest::
|
38
|
+
* {Digest::CRC32Jam CRC32 Jam}
|
39
|
+
* {Digest::CRC32MPEG CRC32 MPEG}
|
40
|
+
* {Digest::CRC32POSIX CRC32 POSIX}
|
41
|
+
* {Digest::CRC32XFER CRC32 XFER}
|
34
42
|
* {Digest::CRC64 CRC64}
|
43
|
+
* {Digest::CRC64Jones CRC64 Jones}
|
44
|
+
* {Digest::CRC64XZ CRC64 XZ}
|
35
45
|
* Pure Ruby implementation.
|
36
46
|
* Provides CRC Tables for optimized calculations.
|
47
|
+
* Supports _optional_ C extensions which increases performance by ~40x.
|
48
|
+
* If the C extensions cannot be compiled for whatever reason, digest-crc
|
49
|
+
will automatically fallback to the pure-Ruby implementation.
|
37
50
|
|
38
51
|
## Install
|
39
52
|
|
@@ -106,6 +119,113 @@ module Digest
|
|
106
119
|
end
|
107
120
|
```
|
108
121
|
|
122
|
+
## Benchmarks
|
123
|
+
|
124
|
+
### Pure Ruby (ruby 2.7.1)
|
125
|
+
|
126
|
+
$ bundle exec rake clean
|
127
|
+
$ bundle exec ./benchmarks.rb
|
128
|
+
Loading Digest::CRC classes ...
|
129
|
+
Generating 1000 8Kb lengthed strings ...
|
130
|
+
Benchmarking Digest::CRC classes ...
|
131
|
+
user system total real
|
132
|
+
Digest::CRC1#update 0.349756 0.000002 0.349758 ( 0.351427)
|
133
|
+
Digest::CRC5#update 1.175206 0.000049 1.175255 ( 1.180975)
|
134
|
+
Digest::CRC8#update 1.023536 0.000015 1.023551 ( 1.029017)
|
135
|
+
Digest::CRC8_1Wire#update 1.012156 0.000000 1.012156 ( 1.017342)
|
136
|
+
Digest::CRC15#update 1.187286 0.000005 1.187291 ( 1.193634)
|
137
|
+
Digest::CRC16#update 0.998527 0.000013 0.998540 ( 1.003940)
|
138
|
+
Digest::CRC16CCITT#update 1.179864 0.000005 1.179869 ( 1.186134)
|
139
|
+
Digest::CRC16DNP#update 1.018969 0.000003 1.018972 ( 1.025248)
|
140
|
+
Digest::CRC16Genibus#update 1.196754 0.000065 1.196819 ( 1.203605)
|
141
|
+
Digest::CRC16Modbus#update 1.007367 0.000000 1.007367 ( 1.012325)
|
142
|
+
Digest::CRC16X25#update 1.044127 0.000000 1.044127 ( 1.052010)
|
143
|
+
Digest::CRC16USB#update 1.012804 0.000000 1.012804 ( 1.018324)
|
144
|
+
Digest::CRC16X25#update 1.009694 0.000000 1.009694 ( 1.015890)
|
145
|
+
Digest::CRC16XModem#update 1.210814 0.000000 1.210814 ( 1.217951)
|
146
|
+
Digest::CRC16ZModem#update 1.175239 0.000000 1.175239 ( 1.181395)
|
147
|
+
Digest::CRC24#update 1.207431 0.000000 1.207431 ( 1.213373)
|
148
|
+
Digest::CRC32#update 1.012334 0.000000 1.012334 ( 1.017671)
|
149
|
+
Digest::CRC32BZip2#update 1.190351 0.000000 1.190351 ( 1.196567)
|
150
|
+
Digest::CRC32c#update 1.021147 0.000000 1.021147 ( 1.027035)
|
151
|
+
Digest::CRC32Jam#update 1.002365 0.000000 1.002365 ( 1.007202)
|
152
|
+
Digest::CRC32MPEG#update 1.161925 0.000000 1.161925 ( 1.168058)
|
153
|
+
Digest::CRC32POSIX#update 1.191860 0.000967 1.192827 ( 1.198722)
|
154
|
+
Digest::CRC32XFER#update 1.217692 0.000000 1.217692 ( 1.224075)
|
155
|
+
Digest::CRC64#update 3.084106 0.000000 3.084106 ( 3.106840)
|
156
|
+
Digest::CRC64Jones#update 3.016687 0.000000 3.016687 ( 3.038963)
|
157
|
+
Digest::CRC64XZ#update 3.019690 0.000000 3.019690 ( 3.040971)
|
158
|
+
|
159
|
+
### C extensions (ruby 2.7.1)
|
160
|
+
o
|
161
|
+
$ bundle exec rake build:c_exts
|
162
|
+
...
|
163
|
+
$ bundle exec ./benchmarks.rb
|
164
|
+
Loading Digest::CRC classes ...
|
165
|
+
Generating 1000 8Kb lengthed strings ...
|
166
|
+
Benchmarking Digest::CRC classes ...
|
167
|
+
user system total real
|
168
|
+
Digest::CRC1#update 0.356025 0.000016 0.356041 ( 0.365345)
|
169
|
+
Digest::CRC5#update 0.023957 0.000001 0.023958 ( 0.024835)
|
170
|
+
Digest::CRC8#update 0.021254 0.000007 0.021261 ( 0.024647)
|
171
|
+
Digest::CRC8_1Wire#update 0.039129 0.000000 0.039129 ( 0.042417)
|
172
|
+
Digest::CRC15#update 0.030285 0.000000 0.030285 ( 0.030560)
|
173
|
+
Digest::CRC16#update 0.023003 0.000000 0.023003 ( 0.023267)
|
174
|
+
Digest::CRC16CCITT#update 0.028207 0.000000 0.028207 ( 0.028467)
|
175
|
+
Digest::CRC16DNP#update 0.022861 0.000000 0.022861 ( 0.023111)
|
176
|
+
Digest::CRC16Genibus#update 0.028041 0.000000 0.028041 ( 0.028359)
|
177
|
+
Digest::CRC16Modbus#update 0.022931 0.000009 0.022940 ( 0.023560)
|
178
|
+
Digest::CRC16X25#update 0.022808 0.000000 0.022808 ( 0.023054)
|
179
|
+
Digest::CRC16USB#update 0.022258 0.000882 0.023140 ( 0.023418)
|
180
|
+
Digest::CRC16X25#update 0.022816 0.000000 0.022816 ( 0.023084)
|
181
|
+
Digest::CRC16XModem#update 0.027984 0.000000 0.027984 ( 0.028269)
|
182
|
+
Digest::CRC16ZModem#update 0.027968 0.000000 0.027968 ( 0.028214)
|
183
|
+
Digest::CRC24#update 0.028426 0.000000 0.028426 ( 0.028687)
|
184
|
+
Digest::CRC32#update 0.022805 0.000000 0.022805 ( 0.023043)
|
185
|
+
Digest::CRC32BZip2#update 0.025519 0.000000 0.025519 ( 0.025797)
|
186
|
+
Digest::CRC32c#update 0.022807 0.000000 0.022807 ( 0.023069)
|
187
|
+
Digest::CRC32Jam#update 0.023006 0.000000 0.023006 ( 0.023231)
|
188
|
+
Digest::CRC32MPEG#update 0.025536 0.000000 0.025536 ( 0.025861)
|
189
|
+
Digest::CRC32POSIX#update 0.025557 0.000000 0.025557 ( 0.025841)
|
190
|
+
Digest::CRC32XFER#update 0.025310 0.000000 0.025310 ( 0.025599)
|
191
|
+
Digest::CRC64#update 0.023182 0.000000 0.023182 ( 0.023421)
|
192
|
+
Digest::CRC64Jones#update 0.022916 0.000000 0.022916 ( 0.023139)
|
193
|
+
Digest::CRC64XZ#update 0.022879 0.000000 0.022879 ( 0.023131)
|
194
|
+
|
195
|
+
### Pure Ruby (jruby 9.2.12.0)
|
196
|
+
|
197
|
+
$ bundle exec ./benchmarks.rb
|
198
|
+
Loading Digest::CRC classes ...
|
199
|
+
Generating 1000 8Kb lengthed strings ...
|
200
|
+
Benchmarking Digest::CRC classes ...
|
201
|
+
user system total real
|
202
|
+
Digest::CRC1#update 1.030000 0.090000 1.120000 ( 0.511189)
|
203
|
+
Digest::CRC5#update 1.620000 0.060000 1.680000 ( 1.096031)
|
204
|
+
Digest::CRC8#update 1.560000 0.070000 1.630000 ( 1.083921)
|
205
|
+
Digest::CRC8_1Wire#update 0.930000 0.040000 0.970000 ( 0.927024)
|
206
|
+
Digest::CRC15#update 1.590000 0.070000 1.660000 ( 1.132566)
|
207
|
+
Digest::CRC16#update 1.650000 0.060000 1.710000 ( 1.074508)
|
208
|
+
Digest::CRC16CCITT#update 1.610000 0.060000 1.670000 ( 1.190860)
|
209
|
+
Digest::CRC16DNP#update 1.270000 0.010000 1.280000 ( 0.938132)
|
210
|
+
Digest::CRC16Genibus#update 1.620000 0.030000 1.650000 ( 1.148556)
|
211
|
+
Digest::CRC16Modbus#update 1.070000 0.020000 1.090000 ( 0.881455)
|
212
|
+
Digest::CRC16X25#update 1.110000 0.010000 1.120000 ( 0.945366)
|
213
|
+
Digest::CRC16USB#update 1.140000 0.000000 1.140000 ( 0.984367)
|
214
|
+
Digest::CRC16X25#update 0.920000 0.010000 0.930000 ( 0.872541)
|
215
|
+
Digest::CRC16XModem#update 1.530000 0.010000 1.540000 ( 1.092838)
|
216
|
+
Digest::CRC16ZModem#update 1.720000 0.010000 1.730000 ( 1.164787)
|
217
|
+
Digest::CRC24#update 1.810000 0.020000 1.830000 ( 1.084953)
|
218
|
+
Digest::CRC32#update 1.590000 0.010000 1.600000 ( 1.105553)
|
219
|
+
Digest::CRC32BZip2#update 1.520000 0.010000 1.530000 ( 1.070839)
|
220
|
+
Digest::CRC32c#update 0.960000 0.010000 0.970000 ( 0.881989)
|
221
|
+
Digest::CRC32Jam#update 1.030000 0.010000 1.040000 ( 0.907208)
|
222
|
+
Digest::CRC32MPEG#update 1.420000 0.010000 1.430000 ( 0.994035)
|
223
|
+
Digest::CRC32POSIX#update 1.530000 0.020000 1.550000 ( 1.106366)
|
224
|
+
Digest::CRC32XFER#update 1.650000 0.010000 1.660000 ( 1.097647)
|
225
|
+
Digest::CRC64#update 3.440000 0.030000 3.470000 ( 2.771806)
|
226
|
+
Digest::CRC64Jones#update 2.630000 0.010000 2.640000 ( 2.628016)
|
227
|
+
Digest::CRC64XZ#update 3.200000 0.020000 3.220000 ( 2.913442)
|
228
|
+
|
109
229
|
## Thanks
|
110
230
|
|
111
231
|
Special thanks go out to the [pycrc](http://www.tty1.net/pycrc/) library
|
data/Rakefile
CHANGED
@@ -10,12 +10,35 @@ require 'rake'
|
|
10
10
|
require 'rubygems/tasks'
|
11
11
|
Gem::Tasks.new
|
12
12
|
|
13
|
+
namespace :build do
|
14
|
+
desc "Builds the C extensions"
|
15
|
+
task :c_exts do
|
16
|
+
Dir.chdir('ext/digest') { sh 'rake' }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
require 'rake/clean'
|
21
|
+
CLEAN.include('ext/digest/crc*/extconf.h')
|
22
|
+
CLEAN.include('ext/digest/crc*/Makefile')
|
23
|
+
CLEAN.include('ext/digest/crc*/*.o')
|
24
|
+
CLEAN.include('ext/digest/crc*/*.so')
|
25
|
+
|
13
26
|
require 'rspec/core/rake_task'
|
14
|
-
|
27
|
+
namespace :spec do
|
28
|
+
RSpec::Core::RakeTask.new(:pure)
|
29
|
+
task :pure => :clean
|
30
|
+
|
31
|
+
if RUBY_ENGINE == 'ruby'
|
32
|
+
RSpec::Core::RakeTask.new(:c_exts)
|
33
|
+
task :c_exts => 'build:c_exts'
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
task :spec => 'spec:pure'
|
38
|
+
task :spec => 'spec:c_exts' if RUBY_ENGINE == 'ruby'
|
15
39
|
task :test => :spec
|
16
40
|
task :default => :spec
|
17
41
|
|
18
42
|
require 'yard'
|
19
|
-
require 'redcarpet'
|
20
|
-
require 'github-markup'
|
21
43
|
YARD::Rake::YardocTask.new
|
44
|
+
task :doc => :yard
|
data/benchmarks.rb
CHANGED
@@ -1,33 +1,46 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require 'benchmark'
|
3
|
-
$LOAD_PATH.unshift(File.expand_path('
|
3
|
+
$LOAD_PATH.unshift(File.expand_path('../ext',__FILE__))
|
4
|
+
$LOAD_PATH.unshift(File.expand_path('../lib',__FILE__))
|
4
5
|
|
5
6
|
CRCs = {
|
6
|
-
'crc1'
|
7
|
-
'crc5'
|
8
|
-
'crc8'
|
9
|
-
'crc8_1wire'
|
10
|
-
'
|
11
|
-
'
|
12
|
-
'
|
13
|
-
'
|
14
|
-
'
|
15
|
-
'
|
16
|
-
'
|
17
|
-
'
|
18
|
-
'
|
19
|
-
'
|
20
|
-
'
|
21
|
-
'
|
22
|
-
'
|
7
|
+
'crc1' => 'CRC1',
|
8
|
+
'crc5' => 'CRC5',
|
9
|
+
'crc8' => 'CRC8',
|
10
|
+
'crc8_1wire' => 'CRC81Wire',
|
11
|
+
'crc15' => 'CRC15',
|
12
|
+
'crc16' => 'CRC16',
|
13
|
+
'crc16_ccitt' => 'CRC16CCITT',
|
14
|
+
'crc16_dnp' => 'CRC16DNP',
|
15
|
+
'crc16_genibus' => 'CRC16Genibus',
|
16
|
+
'crc16_modbus' => 'CRC16Modbus',
|
17
|
+
'crc16_qt' => 'CRC16QT',
|
18
|
+
'crc16_usb' => 'CRC16USB',
|
19
|
+
'crc16_x_25' => 'CRC16X25',
|
20
|
+
'crc16_xmodem' => 'CRC16XModem',
|
21
|
+
'crc16_zmodem' => 'CRC16ZModem',
|
22
|
+
'crc24' => 'CRC24',
|
23
|
+
'crc32' => 'CRC32',
|
24
|
+
'crc32_bzip2' => 'CRC32BZip2',
|
25
|
+
'crc32c' => 'CRC32c',
|
26
|
+
'crc32_jam' => 'CRC32Jam',
|
27
|
+
'crc32_mpeg' => 'CRC32Mpeg',
|
28
|
+
'crc32_posix' => 'CRC32POSIX',
|
29
|
+
'crc32_xfer' => 'CRC32XFER',
|
30
|
+
'crc64' => 'CRC64',
|
31
|
+
'crc64_jones' => 'CRC64Jones',
|
32
|
+
'crc64_xz' => 'CRC64XZ',
|
23
33
|
}
|
24
34
|
|
25
35
|
puts "Loading Digest::CRC classes ..."
|
26
36
|
CRCs.each_key { |crc| require "digest/#{crc}" }
|
27
37
|
|
28
|
-
|
29
|
-
|
30
|
-
|
38
|
+
N = 1000
|
39
|
+
BLOCK_SIZE = 8 * 1024
|
40
|
+
|
41
|
+
puts "Generating #{N} #{BLOCK_SIZE / 1024}Kb lengthed strings ..."
|
42
|
+
SAMPLES = Array.new(N) do
|
43
|
+
Array.new(BLOCK_SIZE) { rand(256).chr }.join
|
31
44
|
end
|
32
45
|
|
33
46
|
puts "Benchmarking Digest::CRC classes ..."
|