guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

02/05: size: Accept several arguments.


From: Ludovic Courtès
Subject: 02/05: size: Accept several arguments.
Date: Tue, 24 May 2016 21:53:34 +0000 (UTC)

civodul pushed a commit to branch master
in repository guix.

commit db761534df3b57122da8e8b05a678182b59a9d3a
Author: Ludovic Courtès <address@hidden>
Date:   Tue May 24 21:37:13 2016 +0200

    size: Accept several arguments.
    
    * guix/scripts/size.scm (display-profile): Display WHOLE at then end.
    (guix-size): Accept several FILES.
    * doc/guix.texi (Invoking guix size): Add example with several items.
---
 doc/guix.texi         |   18 ++++++++++++++++++
 guix/scripts/size.scm |   14 +++++++-------
 2 files changed, 25 insertions(+), 7 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index d88cc25..1b47193 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -5058,6 +5058,24 @@ reports information based on the available substitutes
 (@pxref{Substitutes}).  This makes it possible it to profile disk usage of
 store items that are not even on disk, only available remotely.
 
+You can also specify several package names:
+
address@hidden
+$ guix size coreutils grep sed bash
+store item                               total    self
+/gnu/store/@dots{}-coreutils-8.24          77.8    13.8  13.4%
+/gnu/store/@dots{}-grep-2.22               73.1     0.8   0.8%
+/gnu/store/@dots{}-bash-4.3.42             72.3     4.7   4.6%
+/gnu/store/@dots{}-readline-6.3            67.6     1.2   1.2%
address@hidden
+total: 102.3 MiB
address@hidden example
+
address@hidden
+In this example we see that the combination of the four packages takes
address@hidden in total, which is much less than the sum of each closure
+since they have a lot of dependencies in common.
+
 The available options are:
 
 @table @option
diff --git a/guix/scripts/size.scm b/guix/scripts/size.scm
index 8a79747..8432138 100644
--- a/guix/scripts/size.scm
+++ b/guix/scripts/size.scm
@@ -91,7 +91,8 @@ if ITEM is not in the store."
               (sort profile
                     (match-lambda*
                       ((($ <profile> _ _ total1) ($ <profile> _ _ total2))
-                       (> total1 total2)))))))
+                       (> total1 total2)))))
+    (format port (_ "total: ~,1f MiB~%") (/ whole MiB 1.))))
 
 (define display-profile*
   (lift display-profile %store-monad))
@@ -280,7 +281,7 @@ Report the size of PACKAGE and its dependencies.\n"))
       (match files
         (()
          (leave (_ "missing store item argument\n")))
-        ((file)
+        ((files ..1)
          (leave-on-EPIPE
           ;; Turn off grafts because (1) hydra.gnu.org does not serve grafted
           ;; packages, and (2) they do not make any difference on the
@@ -292,13 +293,12 @@ Report the size of PACKAGE and its dependencies.\n"))
                                  #:substitute-urls urls)
 
               (run-with-store store
-                (mlet* %store-monad ((item    (ensure-store-item file))
-                                     (profile (store-profile (list item))))
+                (mlet* %store-monad ((items   (mapm %store-monad
+                                                    ensure-store-item files))
+                                     (profile (store-profile items)))
                   (if map-file
                       (begin
                         (profile->page-map profile map-file)
                         (return #t))
                       (display-profile* profile)))
-                #:system system)))))
-        ((files ...)
-         (leave (_ "too many arguments\n")))))))
+                #:system system)))))))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]