Skip to content

Commit c3a2ba8

Browse files
committed
Add script to compute number of bytes per package
1 parent a8e6d1e commit c3a2ba8

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

tools/git/scripts/bytes_per_pkg

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Prints the number of bytes in a package.
4+
#
5+
# <package_path> <number_of_bytes>
6+
7+
# Determine root directory:
8+
root="$(git rev-parse --show-toplevel)"
9+
10+
# Define the path to a utility to list packages:
11+
find_pkgs="${root}/tools/scripts/find_packages"
12+
13+
# Define the path to a utility to list files:
14+
find_files="${root}/tools/scripts/find_files"
15+
16+
# Get a list of packages:
17+
pkgs="$(PACKAGES_FILTER=${PACKAGES_FILTER} ${find_pkgs})"
18+
19+
# For each package, determine the number of bytes...
20+
for pkg in ${pkgs}; do
21+
# * `find_files`
22+
# - Find package files.
23+
# * `ls -l`
24+
# - Print file info, which includes number of bytes.
25+
# * `awk '{}'`
26+
# - Compute statistics and print results.
27+
FILES_PATTERN="${FILES_PATTERN}" FILES_FILTER="$pkg/.*" "${find_files}" | xargs ls -l | awk -v pkg="$pkg" '
28+
{
29+
bytes += $5 # number of bytes
30+
}
31+
32+
END {
33+
print pkg OFS bytes
34+
}'
35+
done

0 commit comments

Comments
 (0)