Show execution time of compilation and simulation

This commit is contained in:
Nikolay Puzanov 2022-12-04 10:20:53 +03:00
parent 42f22147ea
commit c6c6744b22

View File

@ -205,6 +205,22 @@
(out (get-string-all p))) (out (get-string-all p)))
(values (close-pipe p) out))) (values (close-pipe p) out)))
;;;
;;; Same as system-to-string but returns execution time (in ms) also
;;;
(define* (system-to-string-with-time cmd #:key (pwd #f))
(let ((start-time (gettimeofday)))
(let-values
(((status out)
(system-to-string cmd #:pwd pwd)))
(let ((stop-time (gettimeofday)))
(values status out
(exact->inexact
(- (+ (* (car stop-time) 1000)
(/ (cdr stop-time) 1000))
(+ (* (car start-time) 1000)
(/ (cdr start-time) 1000)))))))))
;;; ;;;
;;; Execute system command and capture stdout and stderr to string list ;;; Execute system command and capture stdout and stderr to string list
;;; ;;;
@ -218,10 +234,10 @@
;;; ;;;
;;; Make pretty log from executable output ;;; Make pretty log from executable output
;;; ;;;
(define (exe-log-pretty cmdline status out) (define (exe-log-pretty cmdline status out time)
(string-append (string-append
(format "$ ~a\n" cmdline) (format "$ ~a\n" cmdline)
(format "Return code: ~a\n" status) (format "Return code: ~a, Exec time: ~a ms\n" status time)
(if (string-null? out) (if (string-null? out)
"\n" "\n"
(format "--\n~a\n" out)))) (format "--\n~a\n" out))))
@ -339,19 +355,19 @@
(let ((cmdline (format "~a -g2012 -s __~a__ -o ~a -c~a" (let ((cmdline (format "~a -g2012 -s __~a__ -o ~a -c~a"
(wrap-exe IVERILOG-EXE iverilog-wrap) (wrap-exe IVERILOG-EXE iverilog-wrap)
top exe-file command-file))) top exe-file command-file)))
(let-values (((status out) (let-values (((status out time)
(system-to-string cmdline))) (system-to-string-with-time cmdline)))
(let ((compile-log (let ((compile-log
(exe-log-pretty cmdline status out))) (exe-log-pretty cmdline status out time)))
(if (not (zero? status)) (if (not (zero? status))
(values status compile-log) (values status compile-log)
;; Execute ;; Execute
(let ((cmdline (format "~a -N ~a" (wrap-exe VVP-EXE vvp-wrap) exe-file))) (let ((cmdline (format "~a -N ~a" (wrap-exe VVP-EXE vvp-wrap) exe-file)))
(let-values (((status out) (let-values (((status out time)
(system-to-string cmdline))) (system-to-string-with-time cmdline)))
(let ((execution-log (let ((execution-log
(exe-log-pretty cmdline status out))) (exe-log-pretty cmdline status out time)))
(values status (string-append compile-log execution-log))))))))))) (values status (string-append compile-log execution-log)))))))))))
;;; ;;;
@ -364,20 +380,20 @@
(cmdline (format "~a -f ~a" (cmdline (format "~a -f ~a"
(wrap-exe VERILATR-EXE verilator-wrap) (wrap-exe VERILATR-EXE verilator-wrap)
command-file))) command-file)))
(let-values (((status out) (let-values (((status out time)
(system-to-string cmdline))) (system-to-string-with-time cmdline)))
(let ((compile-log (let ((compile-log
(exe-log-pretty cmdline status out))) (exe-log-pretty cmdline status out time)))
(if (not (zero? status)) (if (not (zero? status))
(values status compile-log) (values status compile-log)
;; Execute ;; Execute
(let ((cmdline (wrap-exe (path+ work-dir (format "~a/~a" top top)) (let ((cmdline (wrap-exe (path+ work-dir (format "~a/~a" top top))
verilator-sim-wrap))) verilator-sim-wrap)))
(let-values (((status out) (let-values (((status out time)
(system-to-string cmdline))) (system-to-string-with-time cmdline)))
(let ((execution-log (let ((execution-log
(exe-log-pretty cmdline status out))) (exe-log-pretty cmdline status out time)))
(values status (string-append compile-log execution-log)))))))))) (values status (string-append compile-log execution-log))))))))))
;;; ;;;