Debian Codegraph @

test/generic-map-performance.scm

raw
1 ;;
2 ;; How slow if we make default 'map' and 'for-each' generic functions?
3 ;;
4
5 (use gauche.time)
6 (use gauche.sequence :rename ((map generic-map) (for-each generic-for-each)))
7
8 ((with-module gauche.object generic-build-dispatcher!)
9 generic-for-each 1)
10
11 (define (repeat f)
12 (dotimes [1000]
13 (f identity '(a a a a a a a a a a))))
14
15 (define (bench)
16 (time-these/report '(cpu 10)
17 `((specific . ,(cut repeat for-each))
18 (generic . ,(cut repeat generic-for-each)))))
19
20 (define (main args)
21 (bench)
22 0)