Project

General

Profile

SHA-1 prototype (oldHaskell) » History » Version 6

Greg Burri, 04/05/2009 04:56 PM

1 1 Greg Burri
h1. SHA-1 prototype
2
3 6 Greg Burri
directory : source:/prototypes/01_SHA1
4
5 1 Greg Burri
h2. Goals
6
7
* Compute the SHA-1 of each part of a given file.
8
* Compute the SHA-1 of a stream.
9 6 Greg Burri
* Find the fastest way to compute SHA1, should be at least 40 MB/s.
10 1 Greg Burri
11
h2. Speed measures
12
13 5 Greg Burri
file : @01.wmv@ : 17'639'245 byte ~ 17Mo (buffered)
14 6 Greg Burri
Each measurement is pre-runned once to put the file in cache.
15 5 Greg Burri
16 1 Greg Burri
17
h3. sha1sum from GNU coreutils (Reference)
18
19 4 Greg Burri
speed : 57 MB/s
20 1 Greg Burri
21
<pre>
22
<gburri@overnux:~/code/lang/haskell/SHA1$> time sha1sum < 01.wmv
23
3aec84601612e8c604ac01971e0ecd9d536dbead  -
24
25 4 Greg Burri
real    0m0.301s
26
user    0m0.276s
27
sys     0m0.020s
28 1 Greg Burri
</pre>
29
30
h3. "SHA 1.2.0":http://hackage.haskell.org/cgi-bin/hackage-scripts/package/SHA-1.2.0
31
32 6 Greg Burri
file : _Hash1.hs_
33 1 Greg Burri
speed : 4 times slower (14 MB/s)
34
35
<pre>
36 6 Greg Burri
<gburri@overnux:~/code/lang/haskell/SHA1$> ghc --make -O2 Hash1.hs && time ./Hash1 01.wmv
37 1 Greg Burri
[0 - 3aec84601612e8c604ac01971e0ecd9d536dbead]
38
39 4 Greg Burri
real    0m1.214s
40
user    0m1.200s
41
sys     0m0.012s$
42 1 Greg Burri
</pre>
43
44
45
h3. "Crypto 4.2.0":http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Crypto-4.2.0
46
47
file : _Hash2.hs_
48
speed : 267 times slower (1 MB/s) :
49
50
<pre>
51 6 Greg Burri
<gburri@overnux:~/code/lang/haskell/SHA1$> ghc --make -O2 Hash2.hs && time ./Hash2 01.wmv
52 1 Greg Burri
[0 - Word160 988578912 370337990 78381463 504286621 1399701165]
53
54 4 Greg Burri
real    0m7.628s
55
user    0m7.576s
56
sys     0m0.028s
57 1 Greg Burri
</pre>
58
59
h3. Binding with sha1.h from coreutils
60
61
file : _Hash3.hs_
62
63
TODO...