Skip to content

Commit 616fcde

Browse files
committed
Added new benchmark script called countdown
Countdown is a microbenchmark that focuses on function calls.
1 parent 2f76188 commit 616fcde

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
(define countdown (lambda (n)
2+
(if (< n 101)
3+
(if (< n 1)
4+
0
5+
(countdown (- n 1)))
6+
(countdown
7+
((lambda (x)
8+
(countdown 100)
9+
(- x 100))
10+
n)))))
11+
12+
(countdown 10000)
13+
(countdown 10000)
14+
(countdown 10000)
15+
(countdown 10000)
16+
17+
(define start (now))
18+
(countdown 10000)
19+
(define end (now))
20+
(println (list (quote computation-time) (- end start)))

benchmark/countdown/countdown.sl

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
function countdown(n) {
2+
if (n < 101) {
3+
if (n > 0) {
4+
countdown(n - 1);
5+
}
6+
} else {
7+
countdown(100);
8+
countdown(n - 100);
9+
}
10+
}
11+
12+
function main() {
13+
countdown(10000);
14+
countdown(10000);
15+
countdown(10000);
16+
countdown(10000);
17+
18+
start = nanoTime();
19+
countdown(10000);
20+
end = nanoTime();
21+
println("computation time: " + (end - start) / 1000000);
22+
}

0 commit comments

Comments
 (0)