Welcome to the CHICKEN Scheme pasting service
Science and Benchmarks and Lazyness pasted by DeeEff on Thu Aug 4 21:43:27 2016
;; Lazy Prime Numbers (module lazy-prime-numbers (lazy-prime-numbers) (import chicken scheme) (use lazy-seq) (define (prime? n) (let loop ((d 2)) (cond ((< n (fx* d d)) #t) ((zero? (fxmod n d)) #f) (else (loop (add1 d)))))) (define lazy-prime-numbers (lazy-filter prime? (lazy-numbers start: 2))) ) ;; SRFI-127 Prime Numbers (module lseq-prime-numbers (lseq-prime-numbers) (import chicken scheme) (use srfi-121 srfi-127) (define (prime? n) (let loop ((d 2)) (cond ((< n (fx* d d)) #t) ((zero? (fxmod n d)) #f) (else (loop (add1 d)))))) (define lseq-prime-numbers (lseq-filter prime? (generator->lseq (make-range-generator 2)))) ) ;;; THE BENCHMARK (use srfi-41 streams-math lazy-seq srfi-127) (import lazy-prime-numbers lseq-prime-numbers) (newline) (print* "first run") (newline) (print* "srfi-41: ") (time (print (stream-car (stream-drop 1000 prime-numbers-stream)))) (newline) (print* "lazy-seq: ") (time (print (lazy-head (lazy-drop 1000 lazy-prime-numbers)))) (newline) (print* "srfi-121: ") (time (print (lseq-car (lseq-drop lseq-prime-numbers 1000)))) (newline) (print* "second run") (newline) (print* "srfi-41: ") (time (print (stream-car (stream-drop 1000 prime-numbers-stream)))) (newline) (print* "lazy-seq: ") (time (print (lazy-head (lazy-drop 1000 lazy-prime-numbers)))) (newline) (print* "srfi-121: ") (time (print (lseq-car (lseq-drop lseq-prime-numbers 1000))))
Results of Scientific Benchmark pasted by DeeEff on Thu Aug 4 21:44:14 2016
D:\Users\deeeff\code\playground> csc -O3 scienctific-benchmark.scm D:\Users\deeeff\code\playground> .\scienctific-benchmark.exe first run srfi-41: 7927 0.031s CPU time, 59517/3338 mutations (total/tracked), 3/345 GCs (major/minor) lazy-seq: 7927 0.032s CPU time, 0.016s GC time (major), 8927/92 mutations (total/tracked), 8/36 GCs (major/minor) srfi-121: 7927 0.031s CPU time, 0.031s GC time (major), 9925/1026 mutations (total/tracked), 8/4 GCs (major/minor) second run srfi-41: 7927 0s CPU time, 2002/835 mutations (total/tracked), 0/6 GCs (major/minor) lazy-seq: 7927 0s CPU time, 1/1 mutations (total/tracked), 0/1 GCs (major/minor) srfi-121: 7927 0s CPU time
Changing Nursery Size on Executable pasted by DeeEff on Thu Aug 4 21:53:23 2016
D:\Users\deeeff\code\playground> .\scienctific-benchmark.exe -: 32M first run srfi-41: 7927 0.031s CPU time, 59517/3309 mutations (total/tracked), 4/344 GCs (major/minor) lazy-seq: 7927 0.015s CPU time, 8927/92 mutations (total/tracked), 8/36 GCs (major/minor) srfi-121: 7927 0.016s CPU time, 0.016s GC time (major), 9925/1026 mutations (total/tracked), 8/4 GCs (major/minor) second run srfi-41: 7927 0s CPU time, 2002/837 mutations (total/tracked), 0/6 GCs (major/minor) lazy-seq: 7927 0s CPU time, 1/1 mutations (total/tracked), 0/1 GCs (major/minor) srfi-121: 7927 0s CPU time
Nursery set to 32M with -O0 pasted by DeeEff on Thu Aug 4 22:00:38 2016
D:\Users\jeremy\code\playground> csc scienctific-benchmark.scm D:\Users\jeremy\code\playground> .\scienctific-benchmark.exe -: 32M first run srfi-41: 7927 0.046s CPU time, 0.015s GC time (major), 59517/3309 mutations (total/tracked), 4/344 GCs (major/minor) lazy-seq: 7927 0.032s CPU time, 0.032s GC time (major), 8927/92 mutations (total/tracked), 8/36 GCs (major/minor) srfi-121: 7927 0.015s CPU time, 0.015s GC time (major), 9925/1026 mutations (total/tracked), 8/4 GCs (major/minor) second run srfi-41: 7927 0s CPU time, 2002/837 mutations (total/tracked), 0/6 GCs (major/minor) lazy-seq: 7927 0s CPU time, 1/1 mutations (total/tracked), 0/1 GCs (major/minor) srfi-121: 7927 0s CPU time
After changing 1000 in the original source to 10000 pasted by DeeEff on Thu Aug 4 22:18:37 2016
D:\Users\deeeff\code\playground> csc scienctific-benchmark.scm D:\Users\deeeff\code\playground> .\scienctific-benchmark.exe first run srfi-41: 104743 0.889s CPU time, 0.219s GC time (major), 773271/62276 mutations (total/tracked), 21/7096 GCs (major/minor) lazy-seq: 104743 0.108s CPU time, 114743/1410 mutations (total/tracked), 0/657 GCs (major/minor) srfi-121: 104743 0.063s CPU time, 124741/10494 mutations (total/tracked), 0/246 GCs (major/minor) second run srfi-41: 104743 0.016s CPU time, 20002/9834 mutations (total/tracked), 0/60 GCs (major/minor) lazy-seq: 104743 0s CPU time, 1/1 mutations (total/tracked), 0/13 GCs (major/minor) srfi-121: 104743 0s CPU time, 0/3 GCs (major/minor) D:\Users\deeeff\code\playground> .\scienctific-benchmark.exe -: 32M first run srfi-41: 104743 0.904s CPU time, 0.232s GC time (major), 773271/62276 mutations (total/tracked), 22/7095 GCs (major/minor) lazy-seq: 104743 0.094s CPU time, 114743/1410 mutations (total/tracked), 0/657 GCs (major/minor) srfi-121: 104743 0.078s CPU time, 124741/10494 mutations (total/tracked), 0/246 GCs (major/minor) second run srfi-41: 104743 0.015s CPU time, 20002/9834 mutations (total/tracked), 0/60 GCs (major/minor) lazy-seq: 104743 0s CPU time, 1/1 mutations (total/tracked), 0/13 GCs (major/minor) srfi-121: 104743 0.016s CPU time, 0/3 GCs (major/minor)
Find the 1,000,001st prime number instead of 1001st added by DeeEff on Thu Aug 4 22:33:52 2016
D:\Users\deeeff\code\playground> csc -O3 -strip scienctific-benchmark.scm D:\Users\deeeff\code\playground> .\scienctific-benchmark.exe -: 32M first run lazy-seq: 15485867 98.233s CPU time, 21.394s GC time (major), 16485867/570387 mutations (total/tracked), 753/224577 GCs (major/minor) srfi-121: 15485867 73.82s CPU time, 1.265s GC time (major), 17485865/1331286 mutations (total/tracked), 13/165629 GCs (major/minor) second run lazy-seq: 15485867 0.094s CPU time, 1/1 mutations (total/tracked), 0/1390 GCs (major/minor) srfi-121: 15485867 0.015s CPU time, 0/381 GCs (major/minor)