From 97ccebb2983040f5e1c04e28692812d32af570d8 Mon Sep 17 00:00:00 2001 From: Danny Yoo Date: Sat, 3 Sep 2011 20:23:23 -0400 Subject: [PATCH] making the timing messages a parameter for the builder --- js-assembler/collect-jump-targets.rkt | 3 ++- js-assembler/fracture.rkt | 3 ++- js-assembler/package.rkt | 2 +- make/make.rkt | 8 ++++---- parameters.rkt | 12 ++++++++++-- whalesong-helpers.rkt | 2 +- whalesong.rkt | 10 +++++++++- 7 files changed, 29 insertions(+), 11 deletions(-) diff --git a/js-assembler/collect-jump-targets.rkt b/js-assembler/collect-jump-targets.rkt index fa1ebbc..b21c56f 100644 --- a/js-assembler/collect-jump-targets.rkt +++ b/js-assembler/collect-jump-targets.rkt @@ -3,6 +3,7 @@ "../compiler/il-structs.rkt" "../compiler/lexical-structs.rkt" "../helpers.rkt" + "../parameters.rkt" racket/list) (provide collect-general-jump-targets @@ -146,7 +147,7 @@ (: end-time Real) (define end-time (current-inexact-milliseconds)) - (printf " collect-general-jump-targets: ~a milliseconds\n" (- end-time start-time)) + (fprintf (current-timing-port) " collect-general-jump-targets: ~a milliseconds\n" (- end-time start-time)) result) diff --git a/js-assembler/fracture.rkt b/js-assembler/fracture.rkt index 03b5e6d..33716df 100644 --- a/js-assembler/fracture.rkt +++ b/js-assembler/fracture.rkt @@ -4,6 +4,7 @@ "collect-jump-targets.rkt" "../compiler/il-structs.rkt" "../compiler/expression-structs.rkt" + "../parameters.rkt" racket/list) @@ -96,6 +97,6 @@ (GotoStatement? (car stmts)))]))])))) (define end-time (current-inexact-milliseconds)) - (printf " assemble fracture: ~a milliseconds\n" (- end-time start-time)) + (fprintf (current-timing-port) " assemble fracture: ~a milliseconds\n" (- end-time start-time)) (values blocks entries)) diff --git a/js-assembler/package.rkt b/js-assembler/package.rkt index cec07b9..df12c2d 100644 --- a/js-assembler/package.rkt +++ b/js-assembler/package.rkt @@ -252,7 +252,7 @@ MACHINE.modules[~s] = (assemble/write-invoke stmts temporary-output-port) (fprintf temporary-output-port "(MACHINE, function() { ")]) (define stop-time (current-inexact-milliseconds)) - (printf " assembly: ~s milliseconds\n" (- stop-time start-time)) + (fprintf (current-timing-port) " assembly: ~s milliseconds\n" (- stop-time start-time)) (write-bytes (get-output-bytes temporary-output-port) op) (void)) diff --git a/make/make.rkt b/make/make.rkt index 746a332..2265d01 100644 --- a/make/make.rkt +++ b/make/make.rkt @@ -66,7 +66,7 @@ (define start-time (current-inexact-milliseconds)) (define compiled-code (compile ast 'val next-linkage/drop-multiple)) (define stop-time (current-inexact-milliseconds)) - (printf " compile ast: ~a milliseconds\n" (- stop-time start-time)) + (fprintf (current-timing-port) " compile ast: ~a milliseconds\n" (- stop-time start-time)) (values ast compiled-code))])) @@ -87,7 +87,7 @@ (open-input-bytes (get-output-bytes source-code-op))))))])) (define stop-time (current-inexact-milliseconds)) - (printf " get-ast: ~a milliseconds\n" (- stop-time start-time)) + (fprintf (current-timing-port) " get-ast: ~a milliseconds\n" (- stop-time start-time)) ast) @@ -168,7 +168,7 @@ [(hash-has-key? visited (first sources)) (loop (rest sources))] [else - (printf "compiling a module ~a\n" (source-name (first sources))) + (fprintf (current-timing-port) "compiling a module ~a\n" (source-name (first sources))) (hash-set! visited (first sources) #t) (let*-values ([(this-source) ((current-module-source-compiling-hook) @@ -180,7 +180,7 @@ (define start-time (current-inexact-milliseconds)) (define new-dependencies (map wrap-source (collect-new-dependencies this-source ast))) (define end-time (current-inexact-milliseconds)) - (printf " computing dependencies: ~a milliseconds\n" (- end-time start-time)) + (fprintf (current-timing-port) " computing dependencies: ~a milliseconds\n" (- end-time start-time)) (loop (append new-dependencies (rest sources))) (after-module-statements this-source ast stmts))]))) diff --git a/parameters.rkt b/parameters.rkt index ef0ac01..46de1c4 100644 --- a/parameters.rkt +++ b/parameters.rkt @@ -3,7 +3,8 @@ (require "compiler/expression-structs.rkt" "compiler/lexical-structs.rkt" "sets.rkt" - racket/path) + racket/path + racket/port) (require/typed "logger.rkt" [log-warning (String -> Void)]) @@ -17,7 +18,10 @@ current-seen-unimplemented-kernel-primitives current-kernel-module-locator? current-compress-javascript? - current-report-port) + current-report-port + + current-timing-port + ) @@ -75,6 +79,10 @@ (define current-report-port (make-parameter (current-output-port))) +(: current-timing-port (Parameterof Output-Port)) +(define current-timing-port (make-parameter (open-output-nowhere) ;(current-output-port) + )) + diff --git a/whalesong-helpers.rkt b/whalesong-helpers.rkt index 5182177..f30e1b1 100644 --- a/whalesong-helpers.rkt +++ b/whalesong-helpers.rkt @@ -142,7 +142,7 @@ #:exists 'replace) (define stop-time (current-inexact-milliseconds)) - (printf "Time taken: ~a milliseconds\n" (- stop-time start-time)) + (fprintf (current-timing-port) "Time taken: ~a milliseconds\n" (- stop-time start-time)) )))) diff --git a/whalesong.rkt b/whalesong.rkt index 1608f08..94a5c4d 100755 --- a/whalesong.rkt +++ b/whalesong.rkt @@ -43,6 +43,9 @@ [("-v" "--verbose") ("Display verbose messages.") (current-verbose? #t)] + [("--debug-show-timings") + ("Display debug messages about compilation time.") + (current-timing-port (current-output-port))] [("--compress-javascript") ("Compress JavaScript with Google Closure (requires Java)") (current-compress-javascript? #t)] @@ -65,6 +68,9 @@ [("-v" "--verbose") ("Display verbose messages.") (current-verbose? #t)] + [("--debug-show-timings") + ("Display debug messages about compilation time.") + (current-timing-port (current-output-port))] [("--compress-javascript") ("Compress JavaScript with Google Closure (requires Java)") (current-compress-javascript? #t)] @@ -77,7 +83,9 @@ [("-v" "--verbose") ("Display verbose messages.") (current-verbose? #t)] - + [("--debug-show-timings") + ("Display debug messages about compilation time.") + (current-timing-port (current-output-port))] [("--compress-javascript") ("Compress JavaScript with Google Closure (requires Java)") (current-compress-javascript? #t)]