|
| 1 | + |
| 2 | +DEFAULT_CXX="" |
| 3 | + |
| 4 | +kern="`uname -s`" |
| 5 | +if which g++ >/dev/null; then |
| 6 | + if [ "$kern" = "Darwin" ]; then |
| 7 | + # Don't include g++ on Darwin by default unless it really is g++; the |
| 8 | + # default isn't really g++, it's a wrapper around an LLVM backend. |
| 9 | + # Real g++ has --version output starting with 'g++' |
| 10 | + if g++ --version | head -n 1 | grep -q '^g++'; then |
| 11 | + DEFAULT_CXX="$DEFAULT_CXX g++" |
| 12 | + fi |
| 13 | + else |
| 14 | + DEFAULT_CXX="$DEFAULT_CXX g++" |
| 15 | + fi |
| 16 | +fi |
| 17 | + |
| 18 | +if which clang++ >/dev/null; then |
| 19 | + DEFAULT_CXX="$DEFAULT_CXX clang++" |
| 20 | +fi |
| 21 | + |
| 22 | + |
| 23 | +CXXS="${CXX:-$DEFAULT_CXX}" |
| 24 | + |
| 25 | +python_flags="$( |
| 26 | + for pycfg in python3-config python-config python2-config; do |
| 27 | + if which $pycfg >/dev/null; then |
| 28 | + $pycfg --includes |
| 29 | + $pycfg --ldflags |
| 30 | + break |
| 31 | + fi |
| 32 | + done | tr '\n' ' ')" |
| 33 | + |
| 34 | +CXXFLAGS="${CXXFLAGS:--Iinclude $python_flags -O2 -DNDEBUG -fPIC -std=c++14 -flto -fvisibility=hidden -Wall -Wextra -Wconversion}" |
| 35 | + |
| 36 | +branch="`git rev-parse --abbrev-ref HEAD`" |
| 37 | +commit="`git rev-parse --short HEAD`" |
| 38 | + |
| 39 | +gnutime= |
| 40 | +if [ "`uname -s`" = "Linux" ] && which time >/dev/null; then |
| 41 | + gnutime=1 |
| 42 | +fi |
| 43 | + |
| 44 | +time_command() { |
| 45 | + if [ -n "$gnutime" ]; then |
| 46 | + # Use system `time` on linux to also report max RSS, which bash's built-in can't do |
| 47 | + \time --format='%U user, %e elapsed, %Mk max' "$@" |
| 48 | + else |
| 49 | + TIMEFORMAT="%U user, %E elapsed" |
| 50 | + time "$@" |
| 51 | + fi |
| 52 | +} |
| 53 | + |
| 54 | + |
| 55 | +master= |
| 56 | +if [ "$branch" = "upstream" ] || [ "$branch" = "master" ]; then master=1; fi |
| 57 | + |
| 58 | +pad() { |
| 59 | + printf "%${1}s" "$2" |
| 60 | +} |
| 61 | + |
| 62 | +show_compilers() { |
| 63 | + for CXX in $CXXS; do |
| 64 | + echo -n "$(pad 11 $CXX) is: " |
| 65 | + $CXX --version | head -n 1 |
| 66 | + done |
| 67 | +} |
| 68 | + |
| 69 | + |
| 70 | +title() { |
| 71 | + echo -e "Benchmarking $1 on $branch ($commit)\n---" |
| 72 | + |
| 73 | + show_compilers |
| 74 | + |
| 75 | + echo |
| 76 | +} |
| 77 | + |
0 commit comments