Home | History | Annotate | Download | only in benchmark
      1 #!/bin/bash
      2 # Copyright 2016 Google Inc. All Rights Reserved.
      3 #
      4 # Licensed under the Apache License, Version 2.0 (the "License");
      5 # you may not use this file except in compliance with the License.
      6 # You may obtain a copy of the License at
      7 #
      8 #      http://www.apache.org/licenses/LICENSE-2.0
      9 #
     10 # Unless required by applicable law or agreed to in writing, software
     11 # distributed under the License is distributed on an "AS-IS" BASIS,
     12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13 # See the License for the specific language governing permissions and
     14 # limitations under the License.
     15 
     16 # This is a quick-and-dirty script to analyze the ELF symbol sizes in a binary generated by generate_benchmark.py.
     17 # It can be used to decide which functions should no longer be inlined, to save space.
     18 
     19 if [ "$#" != "1" ]
     20 then
     21     echo "Usage: $0 <executable_file>"
     22     exit 1
     23 fi
     24 
     25 FILE1=$(mktemp)
     26 nm --print-size --size-sort --radix=d "$1" | sort -k 2 | c++filt \
     27 | sed 's/[^ ]* //;s/fruit::impl:://g;s/InvokeConstructorWithInjectedArgVector<.*>::operator()/InvokeConstructorWithInjectedArgVector<...>::operator()/' \
     28 | sed 's/getComponent[0-9]\+/getComponent$N/' \
     29 | sed 's/X[0-9]\+/X$N/g' \
     30 | sed 's/Interface[0-9]\+/Interface$N/g' \
     31 | sed 's/GetBindingDepsHelper<.*>::operator()()/GetBindingDepsHelper<...>::operator()()/' \
     32 | sed 's/\(std::shared_ptr<Interface$N>, \)\+std::shared_ptr<Interface$N>/.../' \
     33 >"$FILE1"
     34 
     35 FILE2=$(mktemp)
     36 python3 -c "
     37 lines = open('$FILE1', 'r').readlines()
     38 total_size = {}
     39 for line in lines:
     40   splits = line.split(' ', maxsplit=1)
     41   total_size[splits[1]] = total_size.get(splits[1], 0) + int(splits[0])
     42 for key, value in total_size.items():
     43   print('%s %s' % (value, key))
     44 " >"$FILE2"
     45 
     46 sort -n "$FILE2"
     47