aboutsummaryrefslogtreecommitdiff
path: root/tests/stream-time.scm.disabled
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2019-04-03 22:21:20 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2019-04-03 22:24:45 +0200
commitc286ee7d410950152177d209c20a843d4a3f8c26 (patch)
treee373e3b04b5b47f21be504fcad65a498a28dc5c7 /tests/stream-time.scm.disabled
parentAdd parser for BYDAY RRULE's. (diff)
downloadcalp-c286ee7d410950152177d209c20a843d4a3f8c26.tar.gz
calp-c286ee7d410950152177d209c20a843d4a3f8c26.tar.xz
Update tests.
Diffstat (limited to '')
-rw-r--r--tests/stream-time.scm.disabled63
1 files changed, 63 insertions, 0 deletions
diff --git a/tests/stream-time.scm.disabled b/tests/stream-time.scm.disabled
new file mode 100644
index 00000000..d604d0f4
--- /dev/null
+++ b/tests/stream-time.scm.disabled
@@ -0,0 +1,63 @@
+;;; Commentary:
+
+;; This is not really a test of calparse, but just some benchmarks on Guile's
+;; built in SRFI-41 (stream) implementation. While running interactively the code
+;; @lisp
+;; (stream 1 2 3)
+;; @end lisp
+;; is extremely slow (0.5s). The problem however seems to go away during
+;; compilation. Note however that
+;; @lisp
+;; (list->stream '(1 2 3))
+;; @end lisp
+;; is fast in both cases.
+
+;;; Code:
+
+(use-modules (srfi srfi-19) ; Time
+ (srfi srfi-41) ; Streams
+ (srfi srfi-64) ; Tests
+ (srfi srfi-71) ; let-multiple
+ (ice-9 format))
+
+;;; TODO use statprof insteadd
+
+(define (timed thunk)
+ "Returns two values, @var{result} and @var{time ellapsed}."
+ (let ((start-time (current-time time-process)))
+ (let ((result (thunk)))
+ (let ((end-time (current-time time-process)))
+ (values result
+ (time-difference end-time start-time))))))
+
+(define-syntax-rule (with-printed-time port expr ...)
+ (let ((result duration (timed (lambda () expr ...))))
+ (format port "~6f :: ~a~%"
+ (+ (time-second duration)
+ (/ (time-nanosecond duration) 1e5))
+ (quote expr ...))))
+
+(with-printed-time #t (stream 1 2 3 4 5))
+(with-printed-time #t (list->stream '(1 2 3 4 5)))
+(with-printed-time #t (stream->list (list->stream '(1 2 3 4 5))))
+(with-printed-time
+ #t (stream-cons
+ 1 (stream-cons
+ 2 (stream-cons
+ 3 (stream-cons
+ 4 (stream-cons
+ 5 stream-null))))))
+
+(display (make-string 60 #\-)) (newline)
+
+(eval-when (load)
+ (with-printed-time #t (stream 1 2 3 4 5))
+ (with-printed-time #t (list->stream '(1 2 3 4 5)))
+ (with-printed-time #t (stream->list (list->stream '(1 2 3 4 5))))
+ (with-printed-time
+ #t (stream-cons
+ 1 (stream-cons
+ 2 (stream-cons
+ 3 (stream-cons
+ 4 (stream-cons
+ 5 stream-null)))))))