;;; the input file: $ wget 'http://layers.openembedded.org/layerindex/api/layerItems/?format=json' -O layerItems.json ;;; First bench $ cat json-bench.scm (use json medea) (define json (car (command-line-arguments))) (display "json: ") (time (with-input-from-file json json-read)) (display "medea: ") (time (with-input-from-file json read-json)) $ csi -s json-bench.scm layerItems.json json: 1.636s CPU time, 0.65s GC time (major), 271932 mutations, 12/893 GCs (major/minor) medea: 1.507s CPU time, 0.141s GC time (major), 162196 mutations, 2/1299 GCs (major/minor) ;;; Now calling medea's read-json before json's json-read: $ cat json-bench.scm (use json medea) (define json (car (command-line-arguments))) (display "medea: ") (time (with-input-from-file json read-json)) (display "json: ") (time (with-input-from-file json json-read)) $ csi -s json-bench.scm layerItems.json medea: 2.066s CPU time, 0.622s GC time (major), 162196 mutations, 18/1283 GCs (major/minor) json: 1.508s CPU time, 0.579s GC time (major), 271932 mutations, 8/897 GCs (major/minor) ;; Warming up doesn't seem to make a difference $ cat json-bench.scm (use utils) (use json medea) (define json (car (command-line-arguments))) (with-output-to-file "/dev/null" (lambda () (print (read-all json)))) (display "medea: ") (time (with-input-from-file json read-json)) (display "json: ") (time (with-input-from-file json json-read)) $ csi -s json-bench.scm layerItems.json medea: 2.249s CPU time, 0.787s GC time (major), 178720 mutations, 22/1279 GCs (major/minor) json: 1.537s CPU time, 0.492s GC time (major), 276972 mutations, 7/899 GCs (major/minor) ;;; Not even calling medea's read-json twice $ cat json-bench.scm (use json medea) (define json (car (command-line-arguments))) (display "medea: ") (time (with-input-from-file json read-json)) (display "medea: ") (time (with-input-from-file json read-json)) (display "json: ") (time (with-input-from-file json json-read)) $ csi -s json-bench.scm layerItems.json medea: 1.951s CPU time, 0.464s GC time (major), 178720 mutations, 16/1285 GCs (major/minor) medea: 2.005s CPU time, 0.567s GC time (major), 178695 mutations, 12/1289 GCs (major/minor) json: 1.56s CPU time, 0.521s GC time (major), 276990 mutations, 8/898 GCs (major/minor) ;;; Calling json's json-read twice and before medea's read-json $ cat json-bench.scm (use json medea) (define json (car (command-line-arguments))) (display "json: ") (time (with-input-from-file json json-read)) (display "json: ") (time (with-input-from-file json json-read)) (display "medea: ") (time (with-input-from-file json read-json)) $ csi -s json-bench.scm layerItems.json json: 1.774s CPU time, 0.678s GC time (major), 276972 mutations, 13/893 GCs (major/minor) json: 0.958s CPU time, 0.062s GC time (major), 276990 mutations, 1/905 GCs (major/minor) medea: 1.598s CPU time, 0.235s GC time (major), 178738 mutations, 3/1298 GCs (major/minor) ;;; Calling both twice, json first $ cat json-bench.scm (use json medea) (define json (car (command-line-arguments))) (display "json: ") (time (with-input-from-file json json-read)) (display "json: ") (time (with-input-from-file json json-read)) (display "medea: ") (time (with-input-from-file json read-json)) (display "medea: ") (time (with-input-from-file json read-json)) $ csi -s json-bench.scm layerItems.json json: 1.634s CPU time, 0.659s GC time (major), 271932 mutations, 12/893 GCs (major/minor) json: 1.272s CPU time, 0.385s GC time (major), 271932 mutations, 4/901 GCs (major/minor) medea: 1.476s CPU time, 0.136s GC time (major), 162196 mutations, 2/1299 GCs (major/minor) medea: 1.855s CPU time, 0.471s GC time (major), 162153 mutations, 10/1291 GCs (major/minor) ;;; Calling both twice, medea first $ cat json-bench.scm (use json medea) (define json (car (command-line-arguments))) (display "medea: ") (time (with-input-from-file json read-json)) (display "medea: ") (time (with-input-from-file json read-json)) (display "json: ") (time (with-input-from-file json json-read)) (display "json: ") (time (with-input-from-file json json-read)) $ csi -s json-bench.scm layerItems.json medea: 2.067s CPU time, 0.626s GC time (major), 162196 mutations, 18/1283 GCs (major/minor) medea: 1.951s CPU time, 0.555s GC time (major), 162153 mutations, 11/1290 GCs (major/minor) json: 1.501s CPU time, 0.576s GC time (major), 271932 mutations, 8/897 GCs (major/minor) json: 1.27s CPU time, 0.387s GC time (major), 271932 mutations, 4/901 GCs (major/minor) ;;; Independent scripts $ cat json.scm (use json) (time (with-input-from-file (car (command-line-arguments)) json-read)) $ cat medea.scm (use medea) (time (with-input-from-file (car (command-line-arguments)) read-json)) $ csi -s json.scm layerItems.json 1.61s CPU time, 0.616s GC time (major), 271932 mutations, 15/890 GCs (major/minor) $ csi -s medea.scm layerItems.json 2.196s CPU time, 0.658s GC time (major), 162196 mutations, 19/1282 GCs (major/minor)