X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=scm%2Flily.scm;h=9d3af0c50d5151085e73b5be985a92a7da077a29;hb=a914a2361f97e564d49dfe2b5a02c100f89f7501;hp=a403861990399ad17a94141c5b3a73ea910fd7ff;hpb=cc18fd6f82df460cc31695c4c31f47f45b7e434e;p=lilypond.git diff --git a/scm/lily.scm b/scm/lily.scm index a403861990..9d3af0c50d 100644 --- a/scm/lily.scm +++ b/scm/lily.scm @@ -5,6 +5,14 @@ ;;;; (c) 1998--2006 Jan Nieuwenhuizen ;;;; Han-Wen Nienhuys +;; Internationalisation: (_i "to be translated") gets an entry in the +;; POT file (gettext ) must be invoked explicitely to do the actual +;; "translation". +;;(define-macro (_i x) x) +;;(define-macro-public _i (x) x) +;;(define-public-macro _i (x) x) +;; Abbrv-PWR! +(defmacro-public _i (x) x) (define (define-scheme-options) (for-each (lambda (x) @@ -29,11 +37,11 @@ ensure that all refs to parsed objects are dead. This is an internal option, an (debug-skylines #f "debug skylines") (delete-intermediate-files #f "delete unusable PostScript files") - (dump-signatures #f "dump output signatures of each system") + (dump-profile #f "dump timing information for each file") (dump-tweaks #f "dump page layout and tweaks for each score having the tweak-key layout property set.") + (dump-signatures #f "dump output signatures of each system. Used for regression testing.") - (eps-box-padding #f "Pad EPS bounding box left edge by this much to guarantee alignment between systems") - + (eps-box-padding #f "Pad EPS bounding box left edge. Guarantee alignment between systems in LaTeX.") (gs-load-fonts #f "load fonts via Ghostscript.") (gui #f "running from gui; redirect stderr to log file") @@ -60,14 +68,12 @@ on errors, and print a stack trace.") (read-file-list #f "Read files to be processed from command line arguments") (safe #f "Run safely") - (strict-infinity-checking #f "If yes, crash on encountering Inf/NaN") - + (strict-infinity-checking #f "If yes, crash on encountering Inf/NaN.") + (separate-log-files #f "Output to FILE.log per file.") (ttf-verbosity 0 "how much verbosity for TTF font embedding?") - (show-available-fonts #f - "List font names available.") - + "List font names available.") (verbose ,(ly:command-line-verbose?) "value for the --verbose flag") ))) @@ -92,12 +98,11 @@ on errors, and print a stack trace.") (srfi srfi-13) (srfi srfi-14) (scm clip-region) - ) - ;; my display -(define-public (myd k v) (display k) (display ": ") (display v) (display ", ")) +(define-public (myd k v) (display k) (display ": ") (display v) (display ", ") + v) (define-public (print . args) (apply format (cons (current-output-port) args))) @@ -350,6 +355,33 @@ The syntax is the same as `define*-public'." (,symbol? . "symbol") (,vector? . "vector"))) +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; timing + +(define (profile-measurements) + (let* ((t (times)) + (stats (gc-stats))) + + (list + (- (+ (tms:cutime t) + (tms:utime t)) + (ly:assoc-get 'gc-time-taken stats)) + + (ly:assoc-get 'total-cells-allocated stats 0) + ))) + +(define (dump-profile base last this) + (let* + ((outname (format "~a.profile" (basename base ".ly"))) + (diff (map (lambda (y) (apply - y)) (zip this last)))) + + (ly:progress "\nWriting timing to ~a..." outname) + (format (open-file outname "w") + "time: ~a\ncells: ~a\n" + (car diff) + (cadr diff) + ))) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; debug mem leaks @@ -474,7 +506,7 @@ The syntax is the same as `define*-public'." )) (if (and (number? (ly:get-option 'job-count)) - (> (length files) (ly:get-option 'job-count))) + (>= (length files) (ly:get-option 'job-count))) (let* ((count (ly:get-option 'job-count)) @@ -516,6 +548,10 @@ The syntax is the same as `define*-public'." (if (pair? errors) (ly:error "Children ~a exited with errors." errors)) + ;; must overwrite individual entries + (if (ly:get-option 'dump-profile) + (dump-profile "lily-run-total" '(0 0) (profile-measurements))) + (exit (if (null? errors) 0 1)))))) @@ -542,26 +578,57 @@ The syntax is the same as `define*-public'." )) (let* ((failed '()) - (first #t) + (separate-logs (ly:get-option 'separate-log-files)) + (do-measurements (ly:get-option 'dump-profile)) (handler (lambda (key failed-file) (set! failed (append (list failed-file) failed))))) + (gc) (for-each (lambda (x) - - ;; We don't carry info across file boundaries - (if first - (set! first #f) - (gc)) + (let* + ((start-measurements (if do-measurements + (profile-measurements) + #f)) + (base (basename x ".ly")) + (all-settings (ly:all-options))) + + (if separate-logs + (ly:stderr-redirect (format "~a.log" base) "w")) - (lilypond-file handler x) - (ly:clear-anonymous-modules) - (if (ly:get-option 'debug-gc) - (dump-gc-protects) - (if (= (random 40) 1) - (ly:reset-all-fonts)))) + (lilypond-file handler x) + (if start-measurements + (dump-profile x start-measurements (profile-measurements))) + + (for-each + (lambda (s) + (ly:set-option (car s) (cdr s))) + all-settings) + + (ly:clear-anonymous-modules) + + (ly:set-option 'debug-gc-assert-parsed-dead #t) + (gc) + (ly:set-option 'debug-gc-assert-parsed-dead #f) + + + (if (ly:get-option 'debug-gc) + (dump-gc-protects) + (if (= (random 40) 1) + (ly:reset-all-fonts))))) files) + + ;; we want the failed-files notice in the aggregrate logfile. + (if (ly:get-option 'separate-logs) + (ly:stderr-redirect + (if (string-or-symbol? (ly:get-option 'log-file)) + (format "~a.log" (ly:get-option 'log-file)) + "/dev/tty") "a")) + + (if (ly:get-option 'dump-profile) + (dump-profile "lily-run-total" '(0 0) (profile-measurements))) + failed)) (define (lilypond-file handler file-name)