office-gobmx/bin/includebloat.awk
Gabor Kelemen b355c9b79e Make bin/includebloat.awk script output prettier
So instead of:
sum total bytes included (excluding system headers): 21793372177
1197253280 132910 9008 /home/gabor/src/core/include/rtl/ustring.hxx
825845085 90207 9155 /home/gabor/src/core/include/rtl/ustring.h

We can see something nicer:
Sum total bytes included (excluding system headers): 21.795.559.123
Total bytes	Size	   Occurrences	Filename
1.197.253.280	132.910	   9.008	/home/gabor/src/core/include/rtl/ustring.hxx
  825.845.085	 90.207	   9.155	/home/gabor/src/core/include/rtl/ustring.h

Change-Id: Iabcaadae964221ed532e7e7e97b10211e37d4857
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150613
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
2023-04-25 10:42:37 +02:00

53 lines
1.7 KiB
Awk
Executable file

#!/usr/bin/gawk -f
# -*- tab-width: 4; indent-tabs-mode: t -*-
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# Generate a list of files included by the C++ compiler during the build
# sorted by the total bytes an included file contributed to preprocessor input.
# usage: first do a full build with "make check", then run this from $BUILDDIR
# NOTE: by default gbuild does not generate dependencies for system headers
# (in particular the C++ standard library), so those will NOT be counted
BEGIN {
cmd = "find workdir/Dep/CxxObject/ -name *.d | xargs cat"
while ((cmd | getline) > 0) {
if ($0 ~ /^ .*\\$/) {
gsub(/^ /, "");
gsub(/ *\\$/, "");
includes[$1]++
if ($2) {
# GCC emits 2 per line if short enough!
includes[$2]++
}
}
}
exit
}
END {
for (inc in includes) {
cmd = "wc -c " inc
if ((cmd | getline) < 0)
print "ERROR on: " cmd
sizes[inc] = $1 # $0 is wc -c output, $1 is size
totals[inc] = $1 * includes[inc]
totalsize += totals[inc]
close(cmd)
}
PROCINFO["sorted_in"] = "@val_num_desc"
printf "Sum total bytes included (excluding system headers): %'d\n", totalsize
print "Total bytes\tSize\t Occurrences\tFilename"
OFS="\t"
for (inc in totals) {
printf "%'13d\t%'7d\t%'8d\t%s\n", totals[inc], sizes[inc], includes[inc], inc
}
}
# vim: set noet sw=4 ts=4: