Skip to content

Commit

Permalink
add a benchmark using foldl
Browse files Browse the repository at this point in the history
  • Loading branch information
countvajhula committed Oct 6, 2023
1 parent 9298580 commit f78af67
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions qi-sdk/profile/nonlocal/qi/main.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
collatz
filter-map
filter-map-foldr
filter-map-foldl
filter-map-values
range-map-sum
double-list
Expand Down Expand Up @@ -77,6 +78,11 @@
(map sqr)
(foldr + 0)))

(define-flow filter-map-foldl
(~>> (filter odd?)
(map sqr)
(foldl + 0)))

;; (define-flow filter-map
;; (~>> (filter odd?)
;; (map sqr)
Expand Down
4 changes: 4 additions & 0 deletions qi-sdk/profile/nonlocal/racket/main.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
collatz
filter-map
filter-map-foldr
filter-map-foldl
filter-map-values
range-map-sum
double-list
Expand Down Expand Up @@ -63,6 +64,9 @@
(define (filter-map-foldr lst)
(foldr + 0 (map sqr (filter odd? lst))))

(define (filter-map-foldl lst)
(foldl + 0 (map sqr (filter odd? lst))))

(define (filter-map-values . vs)
(apply values
(map sqr (filter odd? vs))))
Expand Down
3 changes: 3 additions & 0 deletions qi-sdk/profile/nonlocal/spec.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
(bm "filter-map-foldr"
check-large-list
50000)
(bm "filter-map-foldl"
check-large-list
50000)
(bm "range-map-sum"
check-value-large
5000)
Expand Down

0 comments on commit f78af67

Please sign in to comment.