;;;; ;from mathh.scm (define (log-with-base b) (let ((lnb (log b))) (lambda (n) (/ (log n) lnb) ) ) ) (define log10 (log-with-base 10)) ;; (define (bigO a) (round (log10 a))) (define (bigO< a b) (< (bigO a) (bigO b))) (define (bigO= a b) (= (bigO a) (bigO b))) (define (bigO-compare a b) (if (bigO< a b) -1 (if (bigO= a b) 0 1))) ;; (define-syntax test-bigO (syntax-rules () ((_ ?O ?expr) (let ((_expr ?expr)) (import (only (chicken string) ->string)) (test-bigO (->string _expr) ?O _expr) ) ) ((_ ?msg ?O ?expr) (begin #;(gloss ?expr) (test-assert ?msg (bigO= ?O ?expr))) ) ) ) ;; (define-syntax stats-item (syntax-rules () ((stats-item ?key ?stats) (stats-ref ?stats '?key)) ) ) (define (stats-ref stats key) (import (only (chicken base) alist-ref)) (alist-ref key stats) ) (define (bigO-stats-test expO stats key) (test-bigO (symbol->string key) expO (stats-ref stats key)) ) (define (bigO-stats-tests expO stats #!optional (keys (map car stats))) (for-each (cut bigO-stats-test expO stats <>) keys) )