You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I wanted to easily compare different implementations, and started with hashing / digests.
In this PR, first the bench/speed.exe has a split-off helper.ml (no surprises) ;)
Then, I developed bench/digests.exe which tests nocrypto (https://github.com/hannesm/ocaml-nocrypto/tree/compiles - 0.5.4-2 plus allowing newer cstruct releases to avoid lots of changes in my switch), mirage-crypto (commit 6fa26bd), digestif 1.1.4, ocaml-sha 1.15.4, cryptokit 1.19, OCaml 4.14.1 and openssl 3.0.12
All tests are run on my i7-5600U CPU @ 2.60GHz using FreeBSD-14, OCaml 4.14.1 (happy to see numbers on other architectures / processors):
Resuls:
MD5
size
nocrypto
mirage-cry
digestif
stdlib
cryptokit
openssl
16
51.682
63.650
78.144
* 107.970*
90.273
59.678
64
148.387
172.181
195.855
* 230.107*
205.056
169.489
256
313.978
332.245
357.565
* 385.844*
361.911
364.497
1024
433.760
445.244
455.512
464.499
454.579
* 513.199*
8192
486.566
489.529
491.404
492.987
490.263
* 587.799*
First column in bytes, all others in MB/s (1MB = 1024 * 1024)
SHA1
size
nocrypto
mirage-cry
digestif
ocaml-sha
cryptokit
openssl
16
43.659
54.273
65.635
* 74.074*
52.385
56.167
64
122.322
142.711
161.865
* 176.676*
116.828
164.608
256
260.846
279.374
298.677
315.168
199.342
* 398.186*
1024
364.759
375.541
385.924
393.510
245.253
* 614.528*
8192
416.407
415.313
420.857
430.265
261.766
* 736.483*
First column in bytes, all others in MB/s (1MB = 1024 * 1024)
SHA256
size
nocrypto
mirage-cry
digestif
ocaml-sha
cryptokit
openssl
16
26.480
31.774
34.243
36.839
34.678
* 38.340*
64
69.416
77.409
82.467
81.558
76.503
* 99.244*
256
131.065
139.294
142.987
137.850
129.533
* 219.244*
1024
171.909
173.974
175.883
163.997
157.563
* 305.108*
8192
188.027
188.982
188.704
180.706
168.621
* 341.120*
First column in bytes, all others in MB/s (1MB = 1024 * 1024)
SHA512
size
nocrypto
mirage-cry
digestif
ocaml-sha
cryptokit
openssl
16
23.323
25.765
25.326
23.991
25.605
* 30.038*
64
92.719
103.203
99.902
104.559
110.152
* 120.589*
256
165.876
167.433
158.540
156.484
167.372
* 244.509*
1024
243.956
237.645
235.108
230.279
234.339
* 387.885*
8192
282.661
269.457
270.386
253.435
266.440
* 487.495*
First column in bytes, all others in MB/s (1MB = 1024 * 1024)
Note, the hacl_star package doesn't build on FreeBSD, thus it is not present above. And I patched the hacl_x25519 to use Cstruct.length (and thus a recent cstruct).
According to /dev/cpuinfo my vcpus are i7-1365U running at 2688.006Hz, and the laptop was wallpluged when benchmarking.
Here are my results but it's hard to understand the different behavior, MD5 results, as well as nocrypto, mirage-crypto, digestif and cruptokit, are quite similar to @hannesm, but openssl significantly outperforms on the SHA1 and 256 suites:
hmm, was there some trick to add some private opam package with the dependencies to get this compiling in CI -- while "private" means that a dune-publish does not accidentally publish that opam package? or is that just something I dreamed of - and we can either live with "ocaml-ci" not finding the dependencies and failing, or add another opam package where we need to be careful to never publish it in a release?
since digest algorithms have been removed from mirage-crypto, this is no longer very relevant. developing benchmarks for the various ocaml libraries and openssl as baseline is still on our list, and will hopefully land soon in this repository :)
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I wanted to easily compare different implementations, and started with hashing / digests.
In this PR, first the
bench/speed.exe
has a split-off helper.ml (no surprises) ;)Then, I developed
bench/digests.exe
which tests nocrypto (https://github.com/hannesm/ocaml-nocrypto/tree/compiles - 0.5.4-2 plus allowing newer cstruct releases to avoid lots of changes in my switch), mirage-crypto (commit 6fa26bd), digestif 1.1.4, ocaml-sha 1.15.4, cryptokit 1.19, OCaml 4.14.1 and openssl 3.0.12All tests are run on my i7-5600U CPU @ 2.60GHz using FreeBSD-14, OCaml 4.14.1 (happy to see numbers on other architectures / processors):
Resuls:
MD5
First column in bytes, all others in MB/s (1MB = 1024 * 1024)
SHA1
First column in bytes, all others in MB/s (1MB = 1024 * 1024)
SHA256
First column in bytes, all others in MB/s (1MB = 1024 * 1024)
SHA512
First column in bytes, all others in MB/s (1MB = 1024 * 1024)