summaryrefslogtreecommitdiffstats
path: root/scripts/size.sh
blob: f772a774f538e79a8499cbdab6b92a39d9c260a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/bash
#
# size.sh is used to bisect the repository and find changes that negatively
# impacted the gotop binary size. It does this by building gotop and exiting
# successfully if the binary size is under a defined amount.
# 
# Example:
# ```
# git bisect start
# git bisect bad master
# git bisect good 755037d211cc8e58e9ce43ee74a95a3036053dee
# git bisect run ./size
# ```

GOODSIZE=6000000

# Caleb's directory structure was different from the current structure, so
# we have to find the main package first.
pt=$(dirname $(find . -name main.go))
# Give the executable a unique-ish name
fn=gotop_$(git rev-list -1 HEAD)
go build -o $fn $pt
sz=$(ls -l $fn | awk '{print $5}')
git checkout -- .
[[ $sz -gt $GOODSIZE ]] && exit 1
exit 0