summaryrefslogtreecommitdiffstats
path: root/tools/dump-package-stats
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2009-03-03 18:28:14 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2009-03-03 18:28:14 -0800
commit05806d7af62e07c6225b2e7103a1b115ecf6c9ad (patch)
tree4b825dc642cb6eb9a060e54bf8d69288fbee4904 /tools/dump-package-stats
parent094268cf8cb37b9d904c8a1e3559cdd46d73cf66 (diff)
downloadbuild-05806d7af62e07c6225b2e7103a1b115ecf6c9ad.zip
build-05806d7af62e07c6225b2e7103a1b115ecf6c9ad.tar.gz
build-05806d7af62e07c6225b2e7103a1b115ecf6c9ad.tar.bz2
auto import from //depot/cupcake/@135843
Diffstat (limited to 'tools/dump-package-stats')
-rwxr-xr-xtools/dump-package-stats152
1 files changed, 0 insertions, 152 deletions
diff --git a/tools/dump-package-stats b/tools/dump-package-stats
deleted file mode 100755
index 589bab5..0000000
--- a/tools/dump-package-stats
+++ /dev/null
@@ -1,152 +0,0 @@
-#!/bin/bash
-#
-# Copyright (C) 2007 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-PROGNAME=`basename $0`
-
-function fail ()
-{
- if [ ! -z "$@" ]
- then
- echo "$PROGNAME: ERROR: $@" >&2
- fi
- echo "$PROGNAME: ERROR: failed." >&2
- exit 1
-}
-
-function usage ()
-{
- cat << HERE
-usage: $PROGNAME <.jar/.apk-file-list>
- Dumps a summary of the compressed and uncompressed sizes of various
- types of files in each package. Emits one line per package.
- Packages must be zipfiles, readable using "unzip".
-
- Example output line:
-
- filesize=642684 all=603288/919304 dex=119529/353815 name="out/App.apk"
-
- filesize: the size of the package on disk
- name: the name of the package as passed to $PROGNAME
-
- These fields are presented as <uncompressed bytes>/<compressed bytes>:
-
- all: the sum of all entries in the package
- dex: the sum of all "*.dex" entries in the package
-HERE
- exit 1
-}
-
-if [ $# -lt 1 ]
-then
- usage
-fi
-
-UNAME=`uname`
-if [ "x$UNAME" = "xDarwin" ]
-then
- statArgs="-f %z"
-elif [ "x$UNAME" = "xLinux" ]
-then
- statArgs="-c %s"
-else
- fail "Unknown uname $UNAME"
-fi
-
-function printFileSize ()
-{
- stat $statArgs $1
-}
-
-for file
-do
- if [ ! -f "$file" ]
- then
- fail "$file doesn't exist or isn't a file"
- fi
- unzip -lv "$file" | awk '
- BEGIN {
- total_compressed = 0;
- total_uncompressed = 0;
- dex_compressed = 0;
- dex_uncompressed = 0;
- }
-
- # Make sure the output of unzip -lv looks like something we expect.
- #
- NR == "1" {
- if ($1 != "Archive:") {
- print "'$PROGNAME': ERROR: Unexpected zip listing format" > \
- "/dev/stderr";
- print "'$PROGNAME': ERROR: Line 1 is \"" $0 "\"" > \
- "/dev/stderr";
- failed = 1;
- exit 1;
- }
- }
- NR == "2" {
- if (NF != "8" ||
- $1 != "Length" ||
- $2 != "Method" ||
- $3 != "Size" ||
- $4 != "Ratio" ||
- $5 != "Date" ||
- $6 != "Time" ||
- $7 != "CRC-32" ||
- $8 != "Name")
- {
- print "'$PROGNAME': ERROR: Unexpected zip listing format" > \
- "/dev/stderr";
- print "'$PROGNAME': ERROR: Line 2 is \"" $0 "\"" > \
- "/dev/stderr";
- failed = 1;
- exit 1;
- } else {
- saw_listing = 1;
- }
- }
-
- # Only look for lines where the ratio is the fourth column;
- # this filters out the header and footer.
- #
- $4 ~ /%$/ {
- uncompressed = $1;
- compressed = $3;
- if ($0 ~ /.dex$/) {
- dex_compressed += compressed;
- dex_uncompressed += uncompressed;
- }
- total_compressed += compressed;
- total_uncompressed += uncompressed;
- }
- { next }
-
- END {
- if (!failed && saw_listing) {
- print "filesize='$(printFileSize "$file")'",
- "all=" total_compressed "/" total_uncompressed,
- "dex=" dex_compressed "/" dex_uncompressed,
- "name=\"'"$file"'\"";
- } else {
- exit 1;
- }
- }
- '
- if [ $? -ne 0 ]
- then
- fail "Could not get stats for $file"
- fi
-done