From fce0a555f50737daf31ba2d3385bf9ab5f9b0c4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Mon, 1 Jun 2020 13:58:21 +0200 Subject: Extend and document benchmark main. --- module/entry-points/benchmark.scm | 30 ++++++++++++++++++++++++++---- module/main.scm | 3 ++- 2 files changed, 28 insertions(+), 5 deletions(-) (limited to 'module') diff --git a/module/entry-points/benchmark.scm b/module/entry-points/benchmark.scm index 701d786b..0ff5556d 100644 --- a/module/entry-points/benchmark.scm +++ b/module/entry-points/benchmark.scm @@ -2,16 +2,38 @@ :export (main) :use-module (ice-9 getopt-long) + :use-module (util options) :use-module (util) :use-module (util app) ) (define opt-spec - '()) + `((field (value #t) + (description + (*TOP* + "Which field from the current app to force. Most heavy fields are defined in " + (i "(vcomponent)") "."))) + (enable-output (single-char #\o) + (description + (*TOP* + "Output is be default supressed, since many fields contain way to much data " + "to read. This turns it on again."))) + (help (single-char #\h) (description "Print this help.")))) + (define (main args) - (define opts (getopt-long args opt-spec)) + (define opts (getopt-long args (getopt-opt opt-spec))) + + (define field (and=> (option-ref opts 'field #f) string->symbol)) + + (when (option-ref opts 'help #f) + (print-arg-help opt-spec) + (throw 'return)) + + (unless field + (throw 'argument-error "Field `field' required.")) - (write (getf 'calendars app: (current-app))) -) + (aif (option-ref opts 'enable-output #f) + (write (getf field app: (current-app))) + (getf field app: (current-app)))) diff --git a/module/main.scm b/module/main.scm index c55c892a..8332f566 100644 --- a/module/main.scm +++ b/module/main.scm @@ -88,7 +88,8 @@ "reserializes it back into ICAL format. " "Useful for merging calendars.") - (p (b "benchmark") " does something?") + (p (b "benchmark") " Forces a field from the current app. Preferably used together with " + (i "--statprof") " for some for profiling the code.") (p (b "server") " starts an HTTP server which dynamicly loads and displays event. The " (i "/month/{date}.html") " & " (i "/week/{date}.html") " runs the same output code as " -- cgit v1.2.3