From 61b721dd814dd9d4efe39c929f0125c0030d3a62 Mon Sep 17 00:00:00 2001 From: Eli Barzilay Date: Thu, 9 May 2013 09:42:56 -0400 Subject: [PATCH] Combine the two zo-size tests into one. Also beautify the output. --- collects/meta/zo-size.rkt | 23 -------------- collects/tests/zo-path.rkt | 7 ++--- collects/tests/zo-size.rkt | 61 ++++++++++++++++++++++---------------- 3 files changed, 39 insertions(+), 52 deletions(-) delete mode 100644 collects/meta/zo-size.rkt diff --git a/collects/meta/zo-size.rkt b/collects/meta/zo-size.rkt deleted file mode 100644 index 2b1d8a237e..0000000000 --- a/collects/meta/zo-size.rkt +++ /dev/null @@ -1,23 +0,0 @@ -#lang racket - -(define ht (make-hash)) - -(for ([lcp (current-library-collection-paths)]) - (when (directory-exists? lcp) - (for ([coll (in-list (directory-list lcp))]) - (define coll-path (build-path lcp coll)) - (when (directory-exists? coll-path) - (hash-set! ht - (path->string coll) - (for/sum ([file (in-directory (build-path lcp coll))] - #:when (regexp-match? #rx"[.]zo$" (path->string file))) - (file-size file))))))) - -(define total (for/sum ([(k v) (in-hash ht)]) v)) -(printf "The 'time' line is to trick drdr into graphing\n") -(printf "the size of all of the .zo files, in bytes\n") -(printf "cpu time: ~a real time: ~a gc time: ~a\n" total total total) -(printf "This is the breakdown by collection\n") -(sort (hash-map ht list) - string<=? - #:key car) diff --git a/collects/tests/zo-path.rkt b/collects/tests/zo-path.rkt index 003c21ffc6..3cd85db16f 100644 --- a/collects/tests/zo-path.rkt +++ b/collects/tests/zo-path.rkt @@ -1,16 +1,16 @@ #lang racket (require setup/dirs) -;; Paths from the biuld location shouldn't show up in bytecode files +;; Paths from the build location shouldn't show up in bytecode files ;; or documentation. Check ".zo", ".dep", and ".html" files in the ;; build on the assumption that the first three elements of the ;; build path are unique enough that they shouldn't appear anywhere. -(define rx:dir +(define rx:dir (byte-regexp (regexp-quote (path->bytes - (apply build-path + (apply build-path (take (explode-path (find-collects-dir)) 3)))))) @@ -21,7 +21,6 @@ (lambda (in) (when (regexp-match? rx:dir in) (eprintf "Found ~s in ~s\n" rx:dir name))))))) - (fold-files (check-content #rx"[.](?:zo|dep)$") (void) diff --git a/collects/tests/zo-size.rkt b/collects/tests/zo-size.rkt index a442c39b84..9b76bf01bc 100644 --- a/collects/tests/zo-size.rkt +++ b/collects/tests/zo-size.rkt @@ -1,29 +1,40 @@ #lang racket/base -(require racket/path - racket/match) -(define (indent i) - (for ([t (in-range i)]) - (printf "|"))) +(require racket/match setup/dirs) -(define (dir-zo-size i p) - (parameterize ([current-directory p]) - (define subdir? #f) - (define (has-sub-dir!) - (unless subdir? - (indent i) (printf "~a:\n" p) - (set! subdir? #t))) - (define tot - (for/fold ([size 0]) - ([p (in-list (directory-list))]) - (+ - (match p - [(? directory-exists?) (has-sub-dir!) (dir-zo-size (add1 i) p)] - [(app filename-extension #"zo") (file-size p)] - [else 0]) - size))) - (unless (zero? tot) - (indent i) (printf "~a: ~a\n" p tot)) - tot)) +(define (show-tree t0 [format values]) + (let loop ([t t0] [last? #t] [indent '()]) + (define (I mid last) (cond [(eq? t t0) ""] [last? mid] [else last])) + (for-each display (reverse indent)) + (unless (eq? t t0) (printf "|\n")) + (for-each display (reverse indent)) + (printf "~a~a\n" (I "\\-" "+-") (format (car t))) + (for ([s (cdr t)] [n (in-range (- (length t) 2) -1 -1)]) + (loop s (zero? n) (cons (I " " "| ") indent))))) -(void (dir-zo-size 0 (simplify-path (build-path (collection-path "racket") 'up)))) +(define (zo-size-tree dir) + (parameterize ([current-directory dir]) + (define subs + (filter values + (for/list ([p (in-list (sort (map path->string (directory-list)) + string