tiny perceus fix, but mostly wrote match+rb-tree f-expr/macro for newLisp and benchmarked it. kraken 5-15x faster than newlisp-rbtree-macro, 137x faster than newlisp-rbtree-fexpr. I was suprised at first that the macro and fexpr versions were so close at 8.7x (while interpreted kraken rbtree is 50,000x slower), but after thinking about it it makes sense - the Kraken version has slowdown exponential in the multiple levels of f-exprs ('match' is an fexpr, but then so is 'let' and 'and' and 'lambda'), whereas the newLisp f-expr runtime expands to fast builtins ('let', 'and', etc). And all that exponential f-expr slowdown gets compiled away in Kraken!

This commit is contained in:
Nathan Braswell
2022-07-06 02:34:48 -04:00
parent 2cdfa4dbed
commit e95feb9309
7 changed files with 235 additions and 18 deletions

View File

@@ -0,0 +1,12 @@
#!/usr/bin/env newlisp
(new Tree 'Foo)
(define (make-test-tree n t) (cond ((<= n 0) t)
(true (make-test-tree (- n 1) (begin (t n (= 0 (% n 10))) t)))))
(define (reduce-test-tree t) (let ((sum 0)) (dolist (item (t)) (if (item 1) (setq sum (+ sum 1))))))
(println (reduce-test-tree (make-test-tree (integer (main-args 2)) Foo)))
(exit)