From 3a857db4b99a2a858651e8eba893bdcfc84fd3b3 Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Fri, 27 Apr 2018 23:59:04 +0100 Subject: [PATCH] Box-and-client speed test --- syndicate/syntax.rkt | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/syndicate/syntax.rkt b/syndicate/syntax.rkt index b6fbed5..b77f8a6 100644 --- a/syndicate/syntax.rkt +++ b/syndicate/syntax.rkt @@ -931,4 +931,24 @@ "box: terminating" "client: box has gone")) + (let ((N 25000)) + (test-case + ;; Box-and-client speed test + [(message-struct set-box (new-value)) + (assertion-struct box-state (value)) + (spawn (field [current-value 0]) + (assert (box-state (current-value))) + (stop-when-true (= (current-value) N)) + (on (message (set-box $new-value)) + (current-value new-value))) + (spawn (stop-when (retracted (observe (set-box _)))) + (on (asserted (box-state $v)) + (send! (set-box (+ v 1)))))] + no-crashes + (expected-output) + (it "should be reasonably quick" + (log-info "Rough box-and-client speed: ~a cycles in ~a ms = ~a Hz" + N + (test-run-time) + (/ N (/ (test-run-time) 1000.0)))))) )