Skip to content

Commit

Permalink
Add benchmark script to integerate map/for-each generics
Browse files Browse the repository at this point in the history
  • Loading branch information
shirok committed Nov 8, 2023
1 parent 9f7ffa8 commit 31aa709
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/generic-map-performance.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
;;
;; How slow if we make default 'map' and 'for-each' generic functions?
;;

(use gauche.time)
(use gauche.sequence :rename ((map generic-map) (for-each generic-for-each)))

((with-module gauche.object generic-build-dispatcher!)
generic-for-each 1)

(define (repeat f)
(dotimes [1000]
(f identity '(a a a a a a a a a a))))

(define (bench)
(time-these/report '(cpu 10)
`((specific . ,(cut repeat for-each))
(generic . ,(cut repeat generic-for-each)))))

(define (main args)
(bench)
0)

0 comments on commit 31aa709

Please sign in to comment.