Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 45 additions & 9 deletions benchmarks/bench.scm
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
(require "../cogs/srfi/srfi-28/format.scm")

(define print displayln)

(define (build-release)
Expand All @@ -9,9 +11,10 @@
(define *interpreter-map*
(hash "py"
"python3.13"
;; "scm" "../target/release/steel"
"scm"
"../target/aarch64-apple-darwin/release/steel"
"../target/release/steel"
; "scm"
; "../target/aarch64-apple-darwin/release/steel"
"lua"
"lua"))

Expand All @@ -34,22 +37,55 @@
(run-bench (append (filter (lambda (x) (not (ends-with? x ".lua"))) (directory->bench-command dir))
options)))

(define *benches*
'(("startup" "--warmup" "10" "--min-runs" "100") ("map" "--warmup" "10")
("ack" "--warmup" "10")
("fib" "--warmup" "10" "--min-runs" "40")
("bin-trees" "--warmup" "10")))
(define *bench-hashmap*
(hash
"Startup" '("startup" "--warmup" "10" "--min-runs" "100")
"Map" '("map" "--warmup" "10")
"Ack" '("ack" "--warmup" "10")
"Fib" '("fib" "--warmup" "10" "--min-runs" "40")
"Binary Trees" '("bin-trees" "--warmup" "10")
))

(define *target-path* "../docs/src/benchmarks")

(define (export-md arg-list)
(flatten (cons arg-list
(list "--export-markdown"
(format "~a/~a.md" *target-path* (car arg-list))))))

;; surely we don't need to define this
(define (repeat val times)
(map (λ (_) val) (range 0 times)))

(define (write-newlines num port)
(#%raw-write-string (string-join (repeat "\n" num)) port))

;; TODO make sure the keys are ordered

(define (build-benchmark-doc bench-hashmap)
(define out (open-output-file (format "~a/benchmarks.md" *target-path*)))
(#%raw-write-string "# Benchmarks" out)
(write-newlines 2 out)
(for-each (λ (key) (let ([name (car (hash-ref bench-hashmap key))])
(#%raw-write-string (format "## ~a" key) out)
(write-newlines 2 out)
(#%raw-write-string (format "{{#include ~a.md}}" name) out)
(write-newlines 2 out)))
(hash-keys->list bench-hashmap))
(close-port out))

(define (main)
(print "Building steel for release...")
(build-release)
(print "Running benches...")
(transduce *benches*
(transduce (hash-values->list *bench-hashmap*)
(mapping (lambda (args)
(newline)
(apply bench-group args)))
(apply bench-group (export-md args))))
(into-list))

(build-benchmark-doc *bench-hashmap*)

; (bench-group "bin-trees")
(print "Done"))

Expand Down
2 changes: 1 addition & 1 deletion benchmarks/fib/fib.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ def fib(n):
return fib(n - 1) + fib(n - 2)

start = time.time()
fib(35)
fib(40)
end = time.time()
print(end - start)
2 changes: 1 addition & 1 deletion benchmarks/fib/fib.scm
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@
;;
;; What that looks like -> Inlining a function call?

(fib 35)
(fib 40)
Loading