diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2020-08-21 00:20:47 +0200 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2020-08-21 00:20:47 +0200 |
commit | 69d0eaf0fd63e81a6eb3e2fe2e11a70f86ff6a63 (patch) | |
tree | e971650318c8e2722652cd43ad1e8a5bad866f6d /module/calp/benchmark/parse.scm | |
parent | Helpstring for port config. (diff) | |
download | calp-69d0eaf0fd63e81a6eb3e2fe2e11a70f86ff6a63.tar.gz calp-69d0eaf0fd63e81a6eb3e2fe2e11a70f86ff6a63.tar.xz |
Allow multiple benchmark files.
Diffstat (limited to 'module/calp/benchmark/parse.scm')
-rw-r--r-- | module/calp/benchmark/parse.scm | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/module/calp/benchmark/parse.scm b/module/calp/benchmark/parse.scm new file mode 100644 index 00000000..68a6d5ff --- /dev/null +++ b/module/calp/benchmark/parse.scm @@ -0,0 +1,47 @@ +(define-module (calp benchmark parse) + :use-module (util) + :use-module (glob) + :use-module (statprof) + + :use-module ((srfi srfi-1) :select (concatenate)) + :use-module ((ice-9 ftw) :select (scandir)) + + ) + +(define-public (run-benchmark) + (define all-calendar-files + (statprof + (lambda () + (concatenate + (map (lambda (path) + (map + (lambda (fname) (path-append path fname)) + (scandir path (lambda (s) (and (not (string= "." (string-take s 1))) + (string= "ics" (string-take-right s 3))))))) + (glob "~/.local/var/cal/*")))))) + + (define all-read + (statprof + (lambda () + (map (lambda ( fullname) + (let ((cal (call-with-input-file fullname + (@@ (vcomponent ical parse) read-file)))) + cal)) + all-calendar-files)))) + + (define tokenized + (statprof + (lambda () + (map (lambda (one-read) + (map (@@ (vcomponent ical parse) tokenize) + one-read)) + all-read)))) + + (define parsed + (statprof + (lambda () + (map (@@ (vcomponent ical parse) parse) tokenized)))) + + (format #t "~a files processed~%" + (length parsed)) + ) |