diff options
author | Peter Bex <peter@more-magic.net> | 2025-08-05 11:01:40 +0200 |
---|---|---|
committer | Peter Bex <peter@more-magic.net> | 2025-08-05 11:01:40 +0200 |
commit | 23a9fe858c01c6905486e1a87ac46553482e3802 (patch) | |
tree | 27aa30e0507280196fd8d7c33e07d44aa9d63b0d /benchmarks/benchmark.scm | |
parent | 39f3ea56211d4b6904290dd2f257715c901c25bf (diff) | |
download | slsets-23a9fe858c01c6905486e1a87ac46553482e3802.tar.gz |
Actually use both different sets
The original implementation just diffed the same set with itself,
and needed a workaround for srfi-1's shortcut on the identical list.
Since we're comparing to other implementations with differing sets, it
makes sense to do the same here.
We actually started doing this but ended up just redefining the same
list...
Diffstat (limited to 'benchmarks/benchmark.scm')
-rw-r--r-- | benchmarks/benchmark.scm | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/benchmarks/benchmark.scm b/benchmarks/benchmark.scm index 6ef4044..1b42aa9 100644 --- a/benchmarks/benchmark.scm +++ b/benchmarks/benchmark.scm @@ -27,8 +27,8 @@ (lp (add1 i) (cons (fun i) res))))) -(define lst (list-tabulate size (lambda (i) (string->symbol (conc "x" i))))) -(define lst (list-tabulate size (lambda (i) (string->symbol (conc "y" i))))) +(define lst1 (list-tabulate size (lambda (i) (string->symbol (conc "x" i))))) +(define lst2 (list-tabulate size (lambda (i) (string->symbol (conc "y" i))))) ;; Super-hacky way to determine impact of caching the hash value in a symbol. ;; We abuse the symbol's toplevel value slot to store the hash. A slightly @@ -160,31 +160,36 @@ (let lp ((i 10000)) (case impl ((lset) - (lset-difference eq? lst (cons 'aha lst))) + (lset-difference eq? lst1 lst2)) ((slset) - (slset-difference lst (cons 'aha lst))) + (slset-difference lst1 lst2)) ((symbolset cached-symbolset) (when (eq? impl 'cached-symbolset) (set! symbol-cache? #t)) - (symbolset-difference lst (cons 'aha lst))) + (symbolset-difference lst1 lst2)) ((hash-table cached-hash-table) - (when (pair? lst) + (when (pair? lst1) (when (eq? impl 'cached-hash-table) (set! symbol-cache? #t)) - (let ((ht (make-my-hash-table size))) + (let ((ht1 (make-my-hash-table size)) + (ht2 (make-my-hash-table size))) (begin - (for-each (lambda (x) (my-hash-table-set! ht x #t)) lst) - (set! lst ht)))) - (my-hash-table-difference lst lst)) + (for-each (lambda (x) (my-hash-table-set! ht1 x #t)) lst1) + (for-each (lambda (x) (my-hash-table-set! ht2 x #t)) lst2) + (set! lst1 ht1) + (set! lst2 ht2)))) + (my-hash-table-difference lst1 lst2)) ((srfi-69 cached-srfi-69) - (when (pair? lst) + (when (pair? lst1) (when (eq? impl 'cached-srfi-69) (set! symbol-cache? #t)) - (let ((ht (make-hash-table eq? (if (eq? impl 'cached-srfi-69) hash-symbol symbol-hash) size))) - (begin - (for-each (lambda (x) (hash-table-set! ht x #t)) lst) - (set! lst ht)))) - (srfi-69-hash-table-difference lst lst)) + (let ((ht1 (make-hash-table eq? (if (eq? impl 'cached-srfi-69) hash-symbol symbol-hash) size)) + (ht2 (make-hash-table eq? (if (eq? impl 'cached-srfi-69) hash-symbol symbol-hash) size))) + (for-each (lambda (x) (hash-table-set! ht1 x #t)) lst1) + (for-each (lambda (x) (hash-table-set! ht2 x #t)) lst2) + (set! lst1 ht1) + (set! lst2 ht2))) + (srfi-69-hash-table-difference lst1 lst2)) (else (error "Unknown impl" impl))) (unless (zero? i) (lp (sub1 i)))) |