chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ANN] faster message-digest


From: Kon Lovett
Subject: [ANN] faster message-digest
Date: Wed, 8 Sep 2021 17:49:05 -0700

to anyone* using the message-digest “suite” the new release shows a decent 
speedup

of course this does nothing for the dependency bloat

* P{user(message-digest)} x [user] ~ 1 ;-)

-----

macOS 11.5.2 w/ 3.2 GHz 6-Core Intel Core i7

csc md-v-simple.scm -Dfile -Dsimple -o simple-file
csc md-v-simple.scm -Dstring -Dsimple -o simple-string
csc md-v-simple.scm -Dfile -Dmd -o md-file
csc md-v-simple.scm -Dstring -Dmd -o md-string

#NOTE best of 3

./simple-file
Simple = 90bbbcbab37cde02d31e2955f1ab9e17becab506
1.959s CPU time, 4316/8 mutations (total/tracked), 0/2 GCs (major/minor), 
maximum live heap: 328.84 KiB

./md-file
MD = 90bbbcbab37cde02d31e2955f1ab9e17becab506
1.938s CPU time, 118/105 mutations (total/tracked), 0/1 GCs (major/minor), 
maximum live heap: 391.07 KiB

./simple-string
Simple = f6ac079150b45d4e7037f27b00ab9f74c9ecda55
0.045s CPU time, 431200/1621 mutations (total/tracked), 0/163 GCs 
(major/minor), maximum live heap: 331.16 KiB

./md-string
MD = f6ac079150b45d4e7037f27b00ab9f74c9ecda55
0.035s CPU time, 1136/213 mutations (total/tracked), 0/90 GCs (major/minor), 
maximum live heap: 391.31 KiB

cat >md-v-simple.scm <<EOF
(import scheme (chicken base) (chicken time))

(cond-expand
  (simple
    (import simple-sha1)
    (define *source* "Simple")
    (define-syntax digest-string (syntax-rules () ((digest-string ?str) 
(string->sha1sum ?str))))
    (define-syntax digest-file (syntax-rules () ((digest-file ?fl) (sha1sum 
?fl)))))
  (md
    (import sha1 message-digest-byte-vector message-digest-item 
message-digest-type)
    (define *source* "MD")
    (define *sha1md* (setup-message-digest (sha1-primitive)))
    (define-syntax digest-string (syntax-rules () ((digest-string ?str) 
(message-digest-string *sha1md* ?str))))
    (define-syntax digest-file (syntax-rules () ((digest-file ?fl) 
(message-digest-file *sha1md* ?fl))))))

(cond-expand
  (string
    (define *test-data* (make-string 1627 #\x))
    (define *reps* 10000)
    (define-syntax digest-data (syntax-rules () ((digest-data ?dat) 
(digest-string ?dat)))))
  (file
    ;11MB File
    (define *test-data* "The Periodic Table of Irrational Nonsense.jpg")
    (define *reps* 100)
    (define-syntax digest-data (syntax-rules () ((digest-data ?dat) 
(digest-file ?dat))))))

(print *source* " = " (digest-data *test-data*))
(time (do ((rep 1 (add1 rep))) ((> rep *reps*)) (digest-data *test-data*)))
EOF




reply via email to

[Prev in Thread] Current Thread [Next in Thread]