digest-crc 0.5.0 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/integration.yml +26 -0
- data/.github/workflows/ruby.yml +30 -0
- data/.gitignore +6 -0
- data/ChangeLog.md +132 -1
- data/README.md +128 -0
- data/Rakefile +38 -1
- data/benchmarks.rb +8 -4
- data/digest-crc.gemspec +2 -1
- data/ext/digest/Rakefile +46 -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 +14 -1
- data/lib/digest/crc15.rb +5 -1
- 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 +11 -1
- data/lib/digest/crc16_kermit.rb +5 -1
- data/lib/digest/crc16_modbus.rb +4 -0
- data/lib/digest/crc16_qt.rb +3 -59
- data/lib/digest/crc16_usb.rb +4 -0
- data/lib/digest/crc16_x_25.rb +6 -1
- 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 +6 -1
- data/lib/digest/crc32_mpeg.rb +4 -0
- data/lib/digest/crc32_posix.rb +5 -1
- data/lib/digest/crc32_xfer.rb +15 -1
- 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 +5 -1
- data/lib/digest/crc64_xz.rb +5 -1
- data/lib/digest/crc8.rb +4 -0
- data/lib/digest/crc8_1wire.rb +4 -0
- data/spec/crc16_genibus_spec.rb +3 -3
- data/spec/crc16_qt_spec.rb +5 -5
- data/spec/{crc32_bzip_spec.rb → crc32_bzip2_spec.rb} +0 -0
- data/spec/integration/docker/Dockerfile.base +9 -0
- data/spec/integration/docker/Dockerfile.with-gcc +3 -0
- data/spec/integration/docker/Dockerfile.with-gcc-and-make +3 -0
- data/spec/integration/install_spec.rb +59 -0
- metadata +137 -7
- data/.travis.yml +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d9232bc15248414404921523bad56602e83532f5d8d783c1f90bcbaaec045cd
|
4
|
+
data.tar.gz: 0e33fbe550c55afb0c56a9dce895f584a0eacc2d2957d00008b72338effcd03b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6d6969231e3e6f5ffe90d97627f7e39e318713355009d2848d89e289aeae873a452865d4e34be9871fcc8d4d7725f369ab11dde24c45135ec610519b52c76a6
|
7
|
+
data.tar.gz: 562a7d60009f5ec9fe29ca8aa6555bed1607d7659b2903e3f2efcfb9f12e331e22e0ed370056c7f6d03f8443c282c2659b2192e259880510913c803380edaa5a
|
@@ -0,0 +1,26 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
tags: [ 'v0.*' ]
|
6
|
+
pull_request:
|
7
|
+
paths: [ 'ext/**' ]
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
tests:
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
strategy:
|
13
|
+
fail-fast: false
|
14
|
+
name: Integration Testing
|
15
|
+
steps:
|
16
|
+
- uses: actions/checkout@v2
|
17
|
+
- name: Set up Docker
|
18
|
+
uses: docker-practice/actions-setup-docker@master
|
19
|
+
- name: Set up Ruby
|
20
|
+
uses: ruby/setup-ruby@v1
|
21
|
+
with:
|
22
|
+
ruby-version: 2.7
|
23
|
+
- name: Install dependencies
|
24
|
+
run: bundle install --jobs 4 --retry 3
|
25
|
+
- name: Run integration tests
|
26
|
+
run: bundle exec rake spec:integration
|
@@ -0,0 +1,30 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on: [ push, pull_request ]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
tests:
|
7
|
+
runs-on: ${{ matrix.os }}
|
8
|
+
strategy:
|
9
|
+
fail-fast: false
|
10
|
+
matrix:
|
11
|
+
os:
|
12
|
+
- ubuntu-latest
|
13
|
+
- macos-latest
|
14
|
+
ruby:
|
15
|
+
- 2.4
|
16
|
+
- 2.5
|
17
|
+
- 2.6
|
18
|
+
- 2.7
|
19
|
+
- jruby
|
20
|
+
name: OS ${{ matrix.os }} / Ruby ${{ matrix.ruby }}
|
21
|
+
steps:
|
22
|
+
- uses: actions/checkout@v2
|
23
|
+
- name: Set up Ruby
|
24
|
+
uses: ruby/setup-ruby@v1
|
25
|
+
with:
|
26
|
+
ruby-version: ${{ matrix.ruby }}
|
27
|
+
- name: Install dependencies
|
28
|
+
run: bundle install --jobs 4 --retry 3
|
29
|
+
- name: Run tests
|
30
|
+
run: bundle exec rake spec
|
data/.gitignore
CHANGED
data/ChangeLog.md
CHANGED
@@ -1,3 +1,135 @@
|
|
1
|
+
### 0.6.2 / 2020-12-03
|
2
|
+
|
3
|
+
* Lower the rake dependency to `~> 12.0` for ruby 2.6.
|
4
|
+
* Fixed a bug in `ext/digest/Rakefile` which prevented digest-crc from being
|
5
|
+
installed on systems where C extensions could not be successfully compiled.
|
6
|
+
* Rake's `ruby` method, which in turn calls rake's `sh` method, raises
|
7
|
+
a `RuntimeError` exception when the ruby command fails, causing rake to
|
8
|
+
exit with an error code. Instead, rescue any `RuntimeError` exceptions and
|
9
|
+
fail gracefully.
|
10
|
+
|
11
|
+
### 0.6.1 / 2020-07-02
|
12
|
+
|
13
|
+
* Fix installation issues under bundler by adding rake as an explicit dependency
|
14
|
+
(@rogerluan).
|
15
|
+
|
16
|
+
### 0.6.0 / 2020-07-01
|
17
|
+
|
18
|
+
* Implement _optional_ C extensions for all CRC algorithms, resulting in an
|
19
|
+
average performance improvement of ~40x. Note, if for whatever reason the
|
20
|
+
C extensions cannot be compiled, they will be skipped and the pure-Ruby
|
21
|
+
CRC algorithms will be used instead. If the C extensions were successfully
|
22
|
+
compiled, then they will be loaded and override the pure-Ruby CRC methods with
|
23
|
+
the C equivalents.
|
24
|
+
* Alias {Digest::CRC16QT} to {Digest::CRC16X25}, since they are effectively the same (@dearblue).
|
25
|
+
* Fix {Digest::CRC32::WIDTH} (@dearblue).
|
26
|
+
|
27
|
+
#### pure-Ruby (ruby 2.7.1)
|
28
|
+
|
29
|
+
Loading Digest::CRC classes ...
|
30
|
+
Generating 1000 8Kb lengthed strings ...
|
31
|
+
Benchmarking Digest::CRC classes ...
|
32
|
+
user system total real
|
33
|
+
Digest::CRC1#update 0.412953 0.000000 0.412953 ( 0.414688)
|
34
|
+
Digest::CRC5#update 1.116375 0.000003 1.116378 ( 1.120741)
|
35
|
+
Digest::CRC8#update 0.994263 0.000013 0.994276 ( 1.001079)
|
36
|
+
Digest::CRC8_1Wire#update 0.974115 0.000004 0.974119 ( 0.978186)
|
37
|
+
Digest::CRC15#update 1.139402 0.000927 1.140329 ( 1.146608)
|
38
|
+
Digest::CRC16#update 0.967836 0.000000 0.967836 ( 0.971792)
|
39
|
+
Digest::CRC16CCITT#update 1.118851 0.000000 1.118851 ( 1.123217)
|
40
|
+
Digest::CRC16DNP#update 0.922211 0.000000 0.922211 ( 0.925739)
|
41
|
+
Digest::CRC16Genibus#update 1.120580 0.000000 1.120580 ( 1.124771)
|
42
|
+
Digest::CRC16Modbus#update 0.955612 0.000000 0.955612 ( 0.959463)
|
43
|
+
Digest::CRC16QT#update 8.153403 0.000012 8.153415 ( 8.189977)
|
44
|
+
Digest::CRC16USB#update 0.952557 0.000000 0.952557 ( 0.956145)
|
45
|
+
Digest::CRC16X25#update 0.962295 0.000000 0.962295 ( 0.970401)
|
46
|
+
Digest::CRC16XModem#update 1.120531 0.000000 1.120531 ( 1.124494)
|
47
|
+
Digest::CRC16ZModem#update 1.124226 0.000000 1.124226 ( 1.128632)
|
48
|
+
Digest::CRC24#update 1.126317 0.000000 1.126317 ( 1.130794)
|
49
|
+
Digest::CRC32#update 0.960015 0.000000 0.960015 ( 0.964803)
|
50
|
+
Digest::CRC32BZip2#update 1.128626 0.000000 1.128626 ( 1.133641)
|
51
|
+
Digest::CRC32c#update 0.964047 0.000000 0.964047 ( 0.967456)
|
52
|
+
Digest::CRC32Jam#update 0.959141 0.000972 0.960113 ( 0.967444)
|
53
|
+
Digest::CRC32MPEG#update 1.131119 0.000002 1.131121 ( 1.137440)
|
54
|
+
Digest::CRC32POSIX#update 1.126019 0.000000 1.126019 ( 1.130549)
|
55
|
+
Digest::CRC32XFER#update 1.116598 0.000000 1.116598 ( 1.120595)
|
56
|
+
Digest::CRC64#update 2.665880 0.000928 2.666808 ( 2.680942)
|
57
|
+
Digest::CRC64Jones#update 2.678003 0.000000 2.678003 ( 2.691390)
|
58
|
+
Digest::CRC64XZ#update 2.671395 0.000000 2.671395 ( 2.682684)
|
59
|
+
|
60
|
+
#### pure-Ruby (jruby 9.2.11.1)
|
61
|
+
|
62
|
+
Loading Digest::CRC classes ...
|
63
|
+
Generating 1000 8Kb lengthed strings ...
|
64
|
+
Benchmarking Digest::CRC classes ...
|
65
|
+
user system total real
|
66
|
+
Digest::CRC1#update 0.700000 0.070000 0.770000 ( 0.436112)
|
67
|
+
Digest::CRC5#update 1.930000 0.050000 1.980000 ( 1.084749)
|
68
|
+
Digest::CRC8#update 1.510000 0.060000 1.570000 ( 0.979123)
|
69
|
+
Digest::CRC8_1Wire#update 0.730000 0.030000 0.760000 ( 0.761309)
|
70
|
+
Digest::CRC15#update 1.760000 0.080000 1.840000 ( 1.061413)
|
71
|
+
Digest::CRC16#update 1.560000 0.030000 1.590000 ( 0.951273)
|
72
|
+
Digest::CRC16CCITT#update 1.700000 0.010000 1.710000 ( 1.046854)
|
73
|
+
Digest::CRC16DNP#update 1.490000 0.000000 1.490000 ( 0.902434)
|
74
|
+
Digest::CRC16Genibus#update 1.820000 0.020000 1.840000 ( 1.030269)
|
75
|
+
Digest::CRC16Modbus#update 0.740000 0.010000 0.750000 ( 0.738604)
|
76
|
+
Digest::CRC16QT#update 7.280000 0.040000 7.320000 ( 6.399987)
|
77
|
+
Digest::CRC16USB#update 0.930000 0.000000 0.930000 ( 0.801541)
|
78
|
+
Digest::CRC16X25#update 0.870000 0.000000 0.870000 ( 0.805130)
|
79
|
+
Digest::CRC16XModem#update 1.320000 0.010000 1.330000 ( 0.968956)
|
80
|
+
Digest::CRC16ZModem#update 1.300000 0.010000 1.310000 ( 0.928303)
|
81
|
+
Digest::CRC24#update 1.550000 0.020000 1.570000 ( 1.024450)
|
82
|
+
Digest::CRC32#update 1.260000 0.000000 1.260000 ( 0.913814)
|
83
|
+
Digest::CRC32BZip2#update 1.210000 0.010000 1.220000 ( 0.919086)
|
84
|
+
Digest::CRC32c#update 0.770000 0.010000 0.780000 ( 0.761726)
|
85
|
+
Digest::CRC32Jam#update 0.930000 0.000000 0.930000 ( 0.800468)
|
86
|
+
Digest::CRC32MPEG#update 1.240000 0.010000 1.250000 ( 0.933962)
|
87
|
+
Digest::CRC32POSIX#update 1.290000 0.010000 1.300000 ( 0.925254)
|
88
|
+
Digest::CRC32XFER#update 1.270000 0.000000 1.270000 ( 0.920521)
|
89
|
+
Digest::CRC64#update 3.480000 0.020000 3.500000 ( 2.883794)
|
90
|
+
Digest::CRC64Jones#update 2.740000 0.000000 2.740000 ( 2.738251)
|
91
|
+
Digest::CRC64XZ#update 2.780000 0.010000 2.790000 ( 2.715833)
|
92
|
+
|
93
|
+
|
94
|
+
#### C extensions (ruby 2.7.1)
|
95
|
+
|
96
|
+
Loading Digest::CRC classes ...
|
97
|
+
Generating 1000 8Kb lengthed strings ...
|
98
|
+
Benchmarking Digest::CRC classes ...
|
99
|
+
user system total real
|
100
|
+
Digest::CRC1#update 0.407438 0.000000 0.407438 ( 0.410495)
|
101
|
+
Digest::CRC5#update 0.022873 0.000000 0.022873 ( 0.023796)
|
102
|
+
Digest::CRC8#update 0.020129 0.000000 0.020129 ( 0.020887)
|
103
|
+
Digest::CRC8_1Wire#update 0.020106 0.000000 0.020106 ( 0.020897)
|
104
|
+
Digest::CRC15#update 0.028765 0.000003 0.028768 ( 0.029549)
|
105
|
+
Digest::CRC16#update 0.022176 0.000856 0.023032 ( 0.023153)
|
106
|
+
Digest::CRC16CCITT#update 0.028570 0.000000 0.028570 ( 0.028691)
|
107
|
+
Digest::CRC16DNP#update 0.023240 0.000001 0.023241 ( 0.024008)
|
108
|
+
Digest::CRC16Genibus#update 0.028692 0.000000 0.028692 ( 0.029575)
|
109
|
+
Digest::CRC16Modbus#update 0.023928 0.000000 0.023928 ( 0.024859)
|
110
|
+
Digest::CRC16QT#update 7.965822 0.000968 7.966790 ( 8.001781)
|
111
|
+
Digest::CRC16USB#update 0.023448 0.000001 0.023449 ( 0.024420)
|
112
|
+
Digest::CRC16X25#update 0.023061 0.000000 0.023061 ( 0.023861)
|
113
|
+
Digest::CRC16XModem#update 0.029407 0.000000 0.029407 ( 0.030583)
|
114
|
+
Digest::CRC16ZModem#update 0.029522 0.000000 0.029522 ( 0.030438)
|
115
|
+
Digest::CRC24#update 0.029528 0.000000 0.029528 ( 0.030504)
|
116
|
+
Digest::CRC32#update 0.023306 0.000000 0.023306 ( 0.024278)
|
117
|
+
Digest::CRC32BZip2#update 0.026346 0.000000 0.026346 ( 0.027293)
|
118
|
+
Digest::CRC32c#update 0.023525 0.000000 0.023525 ( 0.024489)
|
119
|
+
Digest::CRC32Jam#update 0.023348 0.000000 0.023348 ( 0.023477)
|
120
|
+
Digest::CRC32MPEG#update 0.026287 0.000000 0.026287 ( 0.027394)
|
121
|
+
Digest::CRC32POSIX#update 0.026063 0.000000 0.026063 ( 0.026986)
|
122
|
+
Digest::CRC32XFER#update 0.026374 0.000000 0.026374 ( 0.027314)
|
123
|
+
Digest::CRC64#update 0.023523 0.000000 0.023523 ( 0.024484)
|
124
|
+
Digest::CRC64Jones#update 0.023479 0.000000 0.023479 ( 0.024432)
|
125
|
+
Digest::CRC64XZ#update 0.024146 0.000000 0.024146 ( 0.025129)
|
126
|
+
|
127
|
+
### 0.5.1 / 2020-03-03
|
128
|
+
|
129
|
+
* Fixed XOR logic in {Digest::CRC16Genibus}.
|
130
|
+
* Freeze all `TABLE` constants.
|
131
|
+
* Added missing documentation.
|
132
|
+
|
1
133
|
### 0.5.0 / 2020-03-01
|
2
134
|
|
3
135
|
* Added {Digest::CRC15}.
|
@@ -57,4 +189,3 @@
|
|
57
189
|
* CRC32
|
58
190
|
* CRC32 Mpeg
|
59
191
|
* CRC64
|
60
|
-
|
data/README.md
CHANGED
@@ -44,6 +44,9 @@ module.
|
|
44
44
|
* {Digest::CRC64XZ CRC64 XZ}
|
45
45
|
* Pure Ruby implementation.
|
46
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.
|
47
50
|
|
48
51
|
## Install
|
49
52
|
|
@@ -51,6 +54,24 @@ module.
|
|
51
54
|
gem install digest-crc
|
52
55
|
```
|
53
56
|
|
57
|
+
**Note:** to enable the C extensions ensure that you are using CRuby and have
|
58
|
+
a C compiler (`gcc` or `clang`) and `make` installed, _before_ installing
|
59
|
+
digest-crc.
|
60
|
+
|
61
|
+
* Debian / Ubuntu:
|
62
|
+
|
63
|
+
$ sudo apt install gcc make
|
64
|
+
|
65
|
+
* RedHat / Fedora:
|
66
|
+
|
67
|
+
$ sudo dnf install gcc make
|
68
|
+
|
69
|
+
* Alpine Linux:
|
70
|
+
|
71
|
+
$ apk add build-base
|
72
|
+
|
73
|
+
* macOS: install XCode
|
74
|
+
|
54
75
|
## Examples
|
55
76
|
|
56
77
|
Calculate a CRC32:
|
@@ -116,6 +137,113 @@ module Digest
|
|
116
137
|
end
|
117
138
|
```
|
118
139
|
|
140
|
+
## Benchmarks
|
141
|
+
|
142
|
+
### Pure Ruby (ruby 2.7.1)
|
143
|
+
|
144
|
+
$ bundle exec rake clean
|
145
|
+
$ bundle exec ./benchmarks.rb
|
146
|
+
Loading Digest::CRC classes ...
|
147
|
+
Generating 1000 8Kb lengthed strings ...
|
148
|
+
Benchmarking Digest::CRC classes ...
|
149
|
+
user system total real
|
150
|
+
Digest::CRC1#update 0.349756 0.000002 0.349758 ( 0.351427)
|
151
|
+
Digest::CRC5#update 1.175206 0.000049 1.175255 ( 1.180975)
|
152
|
+
Digest::CRC8#update 1.023536 0.000015 1.023551 ( 1.029017)
|
153
|
+
Digest::CRC8_1Wire#update 1.012156 0.000000 1.012156 ( 1.017342)
|
154
|
+
Digest::CRC15#update 1.187286 0.000005 1.187291 ( 1.193634)
|
155
|
+
Digest::CRC16#update 0.998527 0.000013 0.998540 ( 1.003940)
|
156
|
+
Digest::CRC16CCITT#update 1.179864 0.000005 1.179869 ( 1.186134)
|
157
|
+
Digest::CRC16DNP#update 1.018969 0.000003 1.018972 ( 1.025248)
|
158
|
+
Digest::CRC16Genibus#update 1.196754 0.000065 1.196819 ( 1.203605)
|
159
|
+
Digest::CRC16Modbus#update 1.007367 0.000000 1.007367 ( 1.012325)
|
160
|
+
Digest::CRC16X25#update 1.044127 0.000000 1.044127 ( 1.052010)
|
161
|
+
Digest::CRC16USB#update 1.012804 0.000000 1.012804 ( 1.018324)
|
162
|
+
Digest::CRC16X25#update 1.009694 0.000000 1.009694 ( 1.015890)
|
163
|
+
Digest::CRC16XModem#update 1.210814 0.000000 1.210814 ( 1.217951)
|
164
|
+
Digest::CRC16ZModem#update 1.175239 0.000000 1.175239 ( 1.181395)
|
165
|
+
Digest::CRC24#update 1.207431 0.000000 1.207431 ( 1.213373)
|
166
|
+
Digest::CRC32#update 1.012334 0.000000 1.012334 ( 1.017671)
|
167
|
+
Digest::CRC32BZip2#update 1.190351 0.000000 1.190351 ( 1.196567)
|
168
|
+
Digest::CRC32c#update 1.021147 0.000000 1.021147 ( 1.027035)
|
169
|
+
Digest::CRC32Jam#update 1.002365 0.000000 1.002365 ( 1.007202)
|
170
|
+
Digest::CRC32MPEG#update 1.161925 0.000000 1.161925 ( 1.168058)
|
171
|
+
Digest::CRC32POSIX#update 1.191860 0.000967 1.192827 ( 1.198722)
|
172
|
+
Digest::CRC32XFER#update 1.217692 0.000000 1.217692 ( 1.224075)
|
173
|
+
Digest::CRC64#update 3.084106 0.000000 3.084106 ( 3.106840)
|
174
|
+
Digest::CRC64Jones#update 3.016687 0.000000 3.016687 ( 3.038963)
|
175
|
+
Digest::CRC64XZ#update 3.019690 0.000000 3.019690 ( 3.040971)
|
176
|
+
|
177
|
+
### C extensions (ruby 2.7.1)
|
178
|
+
|
179
|
+
$ bundle exec rake build:c_exts
|
180
|
+
...
|
181
|
+
$ bundle exec ./benchmarks.rb
|
182
|
+
Loading Digest::CRC classes ...
|
183
|
+
Generating 1000 8Kb lengthed strings ...
|
184
|
+
Benchmarking Digest::CRC classes ...
|
185
|
+
user system total real
|
186
|
+
Digest::CRC1#update 0.356025 0.000016 0.356041 ( 0.365345)
|
187
|
+
Digest::CRC5#update 0.023957 0.000001 0.023958 ( 0.024835)
|
188
|
+
Digest::CRC8#update 0.021254 0.000007 0.021261 ( 0.024647)
|
189
|
+
Digest::CRC8_1Wire#update 0.039129 0.000000 0.039129 ( 0.042417)
|
190
|
+
Digest::CRC15#update 0.030285 0.000000 0.030285 ( 0.030560)
|
191
|
+
Digest::CRC16#update 0.023003 0.000000 0.023003 ( 0.023267)
|
192
|
+
Digest::CRC16CCITT#update 0.028207 0.000000 0.028207 ( 0.028467)
|
193
|
+
Digest::CRC16DNP#update 0.022861 0.000000 0.022861 ( 0.023111)
|
194
|
+
Digest::CRC16Genibus#update 0.028041 0.000000 0.028041 ( 0.028359)
|
195
|
+
Digest::CRC16Modbus#update 0.022931 0.000009 0.022940 ( 0.023560)
|
196
|
+
Digest::CRC16X25#update 0.022808 0.000000 0.022808 ( 0.023054)
|
197
|
+
Digest::CRC16USB#update 0.022258 0.000882 0.023140 ( 0.023418)
|
198
|
+
Digest::CRC16X25#update 0.022816 0.000000 0.022816 ( 0.023084)
|
199
|
+
Digest::CRC16XModem#update 0.027984 0.000000 0.027984 ( 0.028269)
|
200
|
+
Digest::CRC16ZModem#update 0.027968 0.000000 0.027968 ( 0.028214)
|
201
|
+
Digest::CRC24#update 0.028426 0.000000 0.028426 ( 0.028687)
|
202
|
+
Digest::CRC32#update 0.022805 0.000000 0.022805 ( 0.023043)
|
203
|
+
Digest::CRC32BZip2#update 0.025519 0.000000 0.025519 ( 0.025797)
|
204
|
+
Digest::CRC32c#update 0.022807 0.000000 0.022807 ( 0.023069)
|
205
|
+
Digest::CRC32Jam#update 0.023006 0.000000 0.023006 ( 0.023231)
|
206
|
+
Digest::CRC32MPEG#update 0.025536 0.000000 0.025536 ( 0.025861)
|
207
|
+
Digest::CRC32POSIX#update 0.025557 0.000000 0.025557 ( 0.025841)
|
208
|
+
Digest::CRC32XFER#update 0.025310 0.000000 0.025310 ( 0.025599)
|
209
|
+
Digest::CRC64#update 0.023182 0.000000 0.023182 ( 0.023421)
|
210
|
+
Digest::CRC64Jones#update 0.022916 0.000000 0.022916 ( 0.023139)
|
211
|
+
Digest::CRC64XZ#update 0.022879 0.000000 0.022879 ( 0.023131)
|
212
|
+
|
213
|
+
### Pure Ruby (jruby 9.2.12.0)
|
214
|
+
|
215
|
+
$ bundle exec ./benchmarks.rb
|
216
|
+
Loading Digest::CRC classes ...
|
217
|
+
Generating 1000 8Kb lengthed strings ...
|
218
|
+
Benchmarking Digest::CRC classes ...
|
219
|
+
user system total real
|
220
|
+
Digest::CRC1#update 1.030000 0.090000 1.120000 ( 0.511189)
|
221
|
+
Digest::CRC5#update 1.620000 0.060000 1.680000 ( 1.096031)
|
222
|
+
Digest::CRC8#update 1.560000 0.070000 1.630000 ( 1.083921)
|
223
|
+
Digest::CRC8_1Wire#update 0.930000 0.040000 0.970000 ( 0.927024)
|
224
|
+
Digest::CRC15#update 1.590000 0.070000 1.660000 ( 1.132566)
|
225
|
+
Digest::CRC16#update 1.650000 0.060000 1.710000 ( 1.074508)
|
226
|
+
Digest::CRC16CCITT#update 1.610000 0.060000 1.670000 ( 1.190860)
|
227
|
+
Digest::CRC16DNP#update 1.270000 0.010000 1.280000 ( 0.938132)
|
228
|
+
Digest::CRC16Genibus#update 1.620000 0.030000 1.650000 ( 1.148556)
|
229
|
+
Digest::CRC16Modbus#update 1.070000 0.020000 1.090000 ( 0.881455)
|
230
|
+
Digest::CRC16X25#update 1.110000 0.010000 1.120000 ( 0.945366)
|
231
|
+
Digest::CRC16USB#update 1.140000 0.000000 1.140000 ( 0.984367)
|
232
|
+
Digest::CRC16X25#update 0.920000 0.010000 0.930000 ( 0.872541)
|
233
|
+
Digest::CRC16XModem#update 1.530000 0.010000 1.540000 ( 1.092838)
|
234
|
+
Digest::CRC16ZModem#update 1.720000 0.010000 1.730000 ( 1.164787)
|
235
|
+
Digest::CRC24#update 1.810000 0.020000 1.830000 ( 1.084953)
|
236
|
+
Digest::CRC32#update 1.590000 0.010000 1.600000 ( 1.105553)
|
237
|
+
Digest::CRC32BZip2#update 1.520000 0.010000 1.530000 ( 1.070839)
|
238
|
+
Digest::CRC32c#update 0.960000 0.010000 0.970000 ( 0.881989)
|
239
|
+
Digest::CRC32Jam#update 1.030000 0.010000 1.040000 ( 0.907208)
|
240
|
+
Digest::CRC32MPEG#update 1.420000 0.010000 1.430000 ( 0.994035)
|
241
|
+
Digest::CRC32POSIX#update 1.530000 0.020000 1.550000 ( 1.106366)
|
242
|
+
Digest::CRC32XFER#update 1.650000 0.010000 1.660000 ( 1.097647)
|
243
|
+
Digest::CRC64#update 3.440000 0.030000 3.470000 ( 2.771806)
|
244
|
+
Digest::CRC64Jones#update 2.630000 0.010000 2.640000 ( 2.628016)
|
245
|
+
Digest::CRC64XZ#update 3.200000 0.020000 3.220000 ( 2.913442)
|
246
|
+
|
119
247
|
## Thanks
|
120
248
|
|
121
249
|
Special thanks go out to the [pycrc](http://www.tty1.net/pycrc/) library
|
data/Rakefile
CHANGED
@@ -10,8 +10,45 @@ 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
|
+
|
26
|
+
file 'spec/integration/docker/digest-crc.gem' do |t|
|
27
|
+
sh "gem build -o #{t.name} digest-crc.gemspec"
|
28
|
+
end
|
29
|
+
|
13
30
|
require 'rspec/core/rake_task'
|
14
|
-
|
31
|
+
namespace :spec do
|
32
|
+
RSpec::Core::RakeTask.new(:pure) do |t|
|
33
|
+
t.exclude_pattern = 'spec/integration/*_spec.rb'
|
34
|
+
end
|
35
|
+
task :pure => :clean
|
36
|
+
|
37
|
+
if RUBY_ENGINE == 'ruby'
|
38
|
+
RSpec::Core::RakeTask.new(:c_exts) do |t|
|
39
|
+
t.exclude_pattern = 'spec/integration/*_spec.rb'
|
40
|
+
end
|
41
|
+
task :c_exts => 'build:c_exts'
|
42
|
+
end
|
43
|
+
|
44
|
+
RSpec::Core::RakeTask.new(:integration) do |t|
|
45
|
+
t.pattern = 'spec/integration/*_spec.rb'
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
task :spec => 'spec:pure'
|
50
|
+
task :spec => 'spec:c_exts' if RUBY_ENGINE == 'ruby'
|
51
|
+
|
15
52
|
task :test => :spec
|
16
53
|
task :default => :spec
|
17
54
|
|
data/benchmarks.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
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
7
|
'crc1' => 'CRC1',
|
@@ -34,9 +35,12 @@ CRCs = {
|
|
34
35
|
puts "Loading Digest::CRC classes ..."
|
35
36
|
CRCs.each_key { |crc| require "digest/#{crc}" }
|
36
37
|
|
37
|
-
|
38
|
-
|
39
|
-
|
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
|
40
44
|
end
|
41
45
|
|
42
46
|
puts "Benchmarking Digest::CRC classes ..."
|
data/digest-crc.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |gem|
|
|
11
11
|
$LOAD_PATH << lib_dir unless $LOAD_PATH.include?(lib_dir)
|
12
12
|
|
13
13
|
require 'digest/crc/version'
|
14
|
-
Digest::
|
14
|
+
Digest::CRC::VERSION
|
15
15
|
end
|
16
16
|
|
17
17
|
gem.summary = gemspec['summary']
|
@@ -20,6 +20,7 @@ Gem::Specification.new do |gem|
|
|
20
20
|
gem.authors = Array(gemspec['authors'])
|
21
21
|
gem.email = gemspec['email']
|
22
22
|
gem.homepage = gemspec['homepage']
|
23
|
+
gem.metadata = gemspec['metadata'] if gemspec['metadata']
|
23
24
|
|
24
25
|
glob = lambda { |patterns| gem.files & Dir[*patterns] }
|
25
26
|
|