Changeset 38803 in project


Ignore:
Timestamp:
07/26/20 18:43:40 (4 months ago)
Author:
Kon Lovett
Message:

update abstraction overhead note w/ addition of string example

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wiki/eggref/5/message-digest-utils

    r38794 r38803  
    496496the existing public API.
    497497
    498 * Comparison - YMMV
    499 
    500 <enscript highlight=scheme>
    501 ;macOS 10.15.5 w/ 3.2 GHz 6-Core Intel Core i7
    502 ;
    503 ;csc MD-v-simple-results.scm -Dmd && ./MD-v-simple-results
     498* Abstraction overhead (YMMV)
     499
     500<enscript highlight=scheme>
     501;macOS 10.15.6 w/ 3.2 GHz 6-Core Intel Core i7
     502
     503;csc md-v-simple.scm -Dfile -Dsimple -o simple-file
     504;csc md-v-simple.scm -Dstring -Dsimple -o simple-string
     505;csc md-v-simple.scm -Dfile -Dmd -o md-file
     506;csc md-v-simple.scm -Dstring -Dmd -o md-string
     507
     508;./simple-file
     509;=> Simple = 90bbbcbab37cde02d31e2955f1ab9e17becab506
     510;=> 2.207s CPU time, 4316/17 mutations (total/tracked), 0/2 GCs (major/minor), maximum live heap: 328.82 KiB
     511
     512;./md-file
    504513;=> MD = 90bbbcbab37cde02d31e2955f1ab9e17becab506
    505 ;=> 1.966s CPU time, 220/205 mutations (total/tracked), 0/1 GCs (major/minor), maximum live heap: 369.73 KiB
    506 ;
    507 ;csc MD-v-simple-results.scm -Dsimple && ./MD-v-simple-results
    508 ;=> Simple = 90bbbcbab37cde02d31e2955f1ab9e17becab506
    509 ;=> 1.966s CPU time, 4316/20 mutations (total/tracked), 0/2 GCs (major/minor), maximum live heap: 328.68 KiB
     514;=> 2.189s CPU time, 223/208 mutations (total/tracked), 0/1 GCs (major/minor), maximum live heap: 391.99 KiB
     515
     516;./simple-string
     517;=> Simple = c62af4d8bd70d82bca1081f59f5372628f4742f5
     518;=> 0.053s CPU time, 431200/1688 mutations (total/tracked), 1/165 GCs (major/minor), maximum live heap: 330.45 KiB
     519
     520;./md-string
     521;=> MD = c62af4d8bd70d82bca1081f59f5372628f4742f5
     522;=> 0.051s CPU time, 0.001s GC time (major), 37529/27733 mutations (total/tracked), 13/133 GCs (major/minor), maximum live heap: 414.04 KiB
    510523
    511524(import scheme (chicken base) (chicken time) miscmacros)
    512 
    513 ;11MB File
    514 (define-constant TEST-FILE "The Periodic Table of Irrational Nonsense.jpg")
    515 (define-constant REPS 100)
    516525
    517526(cond-expand
    518527  (simple
    519528    (import simple-sha1)
    520     (define source "Simple")
    521     (define-syntax digest
    522       (syntax-rules ()
    523         ((digest ?fl)
    524           (sha1sum ?fl)) ) ))
     529    (define *source* "Simple")
     530    (define-syntax digest-string (syntax-rules () ((digest-string ?str) (string->sha1sum ?str))))
     531    (define-syntax digest-file (syntax-rules () ((digest-file ?fl) (sha1sum ?fl)))))
    525532  (md
    526     (import sha1 message-digest-item)
    527     (define source "MD")
    528     (define sha1 (sha1-primitive))
    529     (define-syntax digest
    530       (syntax-rules ()
    531         ((digest ?fl)
    532           (message-digest-file sha1 ?fl) ) ) ) ) )
    533 
    534 (print source " = " (digest TEST-FILE))
    535 (time (repeat REPS (digest TEST-FILE)))
     533    (import sha1 message-digest-byte-vector message-digest-item)
     534    (define *source* "MD")
     535    (define *sha1* (sha1-primitive))
     536    (define-syntax digest-string (syntax-rules () ((digest-string ?str) (message-digest-string *sha1* ?str))))
     537    (define-syntax digest-file (syntax-rules () ((digest-file ?fl) (message-digest-file *sha1* ?fl))))))
     538
     539(cond-expand
     540  (string
     541    (define *test-data* (make-string 1627 #\x))
     542    (define *reps* 10000)
     543    (define-syntax digest-data (syntax-rules () ((digest-data ?dat) (digest-string ?dat)))))
     544  (file
     545    ;11MB File
     546    (define *test-data* "The Periodic Table of Irrational Nonsense.jpg")
     547    (define *reps* 100)
     548    (define-syntax digest-data (syntax-rules () ((digest-data ?dat) (digest-file ?dat))))))
     549
     550(print *source* " = " (digest-data *test-data*))
     551(time (repeat *reps* (digest-data *test-data*)))
    536552</enscript>
    537553
Note: See TracChangeset for help on using the changeset viewer.