Welcome to the CHICKEN Scheme pasting service

scientific benchmark of srfi-41 vs. lazy-seq pasted by DerGuteMoritz on Mon May 14 23:41:29 2012

(use srfi-41 streams-math lazy-seq lazy-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* "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))))

benchmark results pasted by DerGuteMoritz on Mon May 14 23:42:05 2012

$ csi -s run.scm                                          !

first run
srfi-41: 7927
2.473s CPU time, 1.723s GC time (major), 2634198 mutations, 1063/18713 GCs (major/minor)

lazy-seq: 7927
0.017s CPU time, 0.01s GC time (major), 8936 mutations, 4/261 GCs (major/minor)

second run
srfi-41: 7927
0s CPU time, 2012 mutations, 0/17 GCs (major/minor)

lazy-seq: 7927
0s CPU time, 10 mutations, 0/2 GCs (major/minor)

New benchmark pasted by DerGuteMoritz on Fri May 18 10:29:46 2012

;; This time with 10001st prime number

first run
srfi-41: 104743
294.728s CPU time, 77.713s GC time (major), 252341539 mutations, 14586/1519188 GCs (major/minor)

lazy-seq: 104743
0.197s CPU time, 0.01s GC time (major), 114752 mutations, 1/1227 GCs (major/minor)

second run
srfi-41: 104743
0.017s CPU time, 20012 mutations, 0/145 GCs (major/minor)

lazy-seq: 104743
0.004s CPU time, 11 mutations, 0/9 GCs (major/minor)

lazy-prime-numbers implementation added by DerGuteMoritz on Sun May 20 20:48:53 2012

;; for completeness' sake

(module lazy-prime-numbers

(lazy-prime-numbers)

(import chicken scheme)
(use lazy-seq)

(define lazy-prime-numbers)

(define (prime? n)
  (let loop ((s lazy-prime-numbers))
    (let ((np (lazy-head s)))
      (cond
       ((> np  (sqrt n))       #t)
       ((zero? (modulo n np))  #f)
       (else   (loop (lazy-tail s)))))))

(set! lazy-prime-numbers
      (lazy-seq
        (cons 2 (lazy-filter prime? (lazy-numbers start: 3)))))

)

Your annotation:

Enter a new annotation:

Your nick:
The title of your paste:
Your paste (mandatory) :
Type in the text below:
                             
  __ _  __ _ _____ __  _   _ 
 / _` |/ _` |_  / '_ \| | | |
| (_| | (_| |/ /| |_) | |_| |
 \__, |\__, /___| .__/ \__, |
    |_|   |_|   |_|    |___/ 
Visually impaired? Let me spell it for you (wav file) download WAV