Mercurial > hg > toybox
annotate scripts/bloatcheck @ 994:00c7b6f4104a
Cleanup klogd
Remove #if and inline most functions
author | Felix Janda <felix.janda@posteo.de> |
---|---|
date | Sat, 10 Aug 2013 19:35:11 +0200 |
parents | f3169b2492f1 |
children | ca297cc8a204 |
rev | line source |
---|---|
492
f3169b2492f1
Replace GPL python debug script with BSD shell script.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
1 #!/bin/bash |
f3169b2492f1
Replace GPL python debug script with BSD shell script.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
2 |
f3169b2492f1
Replace GPL python debug script with BSD shell script.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
3 if [ $# -ne 2 ] |
f3169b2492f1
Replace GPL python debug script with BSD shell script.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
4 then |
f3169b2492f1
Replace GPL python debug script with BSD shell script.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
5 echo "usage: bloatcheck old new" |
f3169b2492f1
Replace GPL python debug script with BSD shell script.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
6 exit 1 |
f3169b2492f1
Replace GPL python debug script with BSD shell script.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
7 fi |
f3169b2492f1
Replace GPL python debug script with BSD shell script.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
8 |
f3169b2492f1
Replace GPL python debug script with BSD shell script.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
9 addline() |
f3169b2492f1
Replace GPL python debug script with BSD shell script.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
10 { |
f3169b2492f1
Replace GPL python debug script with BSD shell script.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
11 NEXT="$(printf "%s% $((50-${#LASTNAME}))d% 10d %10d" "$LASTNAME" "$OLD" "$NEW" "$DELTA")" |
f3169b2492f1
Replace GPL python debug script with BSD shell script.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
12 [ -z "$STUFF" ] && |
f3169b2492f1
Replace GPL python debug script with BSD shell script.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
13 STUFF="$NEXT" || |
f3169b2492f1
Replace GPL python debug script with BSD shell script.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
14 STUFF="$(printf "%s\n%s" "$STUFF" "$NEXT")" |
f3169b2492f1
Replace GPL python debug script with BSD shell script.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
15 } |
f3169b2492f1
Replace GPL python debug script with BSD shell script.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
16 |
f3169b2492f1
Replace GPL python debug script with BSD shell script.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
17 diff <(nm --size-sort "$1" | sort -k3,3) \ |
f3169b2492f1
Replace GPL python debug script with BSD shell script.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
18 <(nm --size-sort "$2" | sort -k3,3) | grep '^[<>]' | sort -k4,4 | \ |
f3169b2492f1
Replace GPL python debug script with BSD shell script.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
19 ( |
f3169b2492f1
Replace GPL python debug script with BSD shell script.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
20 LASTNAME= |
f3169b2492f1
Replace GPL python debug script with BSD shell script.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
21 DELTA=0 |
f3169b2492f1
Replace GPL python debug script with BSD shell script.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
22 TOTAL=0 |
f3169b2492f1
Replace GPL python debug script with BSD shell script.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
23 OLD=0 |
f3169b2492f1
Replace GPL python debug script with BSD shell script.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
24 NEW=0 |
f3169b2492f1
Replace GPL python debug script with BSD shell script.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
25 STUFF= |
f3169b2492f1
Replace GPL python debug script with BSD shell script.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
26 |
f3169b2492f1
Replace GPL python debug script with BSD shell script.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
27 printf "name% 46s% 10s% 11s\n" old new delta |
f3169b2492f1
Replace GPL python debug script with BSD shell script.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
28 echo "-----------------------------------------------------------------------" |
f3169b2492f1
Replace GPL python debug script with BSD shell script.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
29 while read a b c d |
f3169b2492f1
Replace GPL python debug script with BSD shell script.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
30 do |
f3169b2492f1
Replace GPL python debug script with BSD shell script.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
31 THISNAME=$(echo " $d" | sed 's/[.][0-9]*$//') |
f3169b2492f1
Replace GPL python debug script with BSD shell script.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
32 |
f3169b2492f1
Replace GPL python debug script with BSD shell script.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
33 if [ "$LASTNAME" != "$THISNAME" ] |
f3169b2492f1
Replace GPL python debug script with BSD shell script.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
34 then |
f3169b2492f1
Replace GPL python debug script with BSD shell script.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
35 TOTAL=$(($TOTAL+$DELTA)) |
f3169b2492f1
Replace GPL python debug script with BSD shell script.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
36 [ $DELTA -ne 0 ] && addline |
f3169b2492f1
Replace GPL python debug script with BSD shell script.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
37 LASTNAME="$THISNAME" |
f3169b2492f1
Replace GPL python debug script with BSD shell script.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
38 DELTA=0 |
f3169b2492f1
Replace GPL python debug script with BSD shell script.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
39 OLD=0 |
f3169b2492f1
Replace GPL python debug script with BSD shell script.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
40 NEW=0 |
f3169b2492f1
Replace GPL python debug script with BSD shell script.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
41 fi |
f3169b2492f1
Replace GPL python debug script with BSD shell script.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
42 |
f3169b2492f1
Replace GPL python debug script with BSD shell script.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
43 SIZE=$(printf "%d" "0x$b") |
f3169b2492f1
Replace GPL python debug script with BSD shell script.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
44 if [ "$a" == "<" ] |
f3169b2492f1
Replace GPL python debug script with BSD shell script.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
45 then |
f3169b2492f1
Replace GPL python debug script with BSD shell script.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
46 OLD=$(($OLD+$SIZE)) |
f3169b2492f1
Replace GPL python debug script with BSD shell script.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
47 SIZE=$((-1*$SIZE)) |
f3169b2492f1
Replace GPL python debug script with BSD shell script.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
48 else |
f3169b2492f1
Replace GPL python debug script with BSD shell script.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
49 NEW=$(($NEW+$SIZE)) |
f3169b2492f1
Replace GPL python debug script with BSD shell script.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
50 fi |
f3169b2492f1
Replace GPL python debug script with BSD shell script.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
51 DELTA=$(($DELTA+$SIZE)) |
f3169b2492f1
Replace GPL python debug script with BSD shell script.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
52 done |
f3169b2492f1
Replace GPL python debug script with BSD shell script.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
53 |
f3169b2492f1
Replace GPL python debug script with BSD shell script.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
54 TOTAL=$(($TOTAL+$DELTA)) |
f3169b2492f1
Replace GPL python debug script with BSD shell script.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
55 [ $DELTA -ne 0 ] && addline |
f3169b2492f1
Replace GPL python debug script with BSD shell script.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
56 |
f3169b2492f1
Replace GPL python debug script with BSD shell script.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
57 echo "$STUFF" | sort -k4,4nr |
f3169b2492f1
Replace GPL python debug script with BSD shell script.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
58 echo "-----------------------------------------------------------------------" |
f3169b2492f1
Replace GPL python debug script with BSD shell script.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
59 printf "% 71d total\n" "$TOTAL" |
f3169b2492f1
Replace GPL python debug script with BSD shell script.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
60 ) |