Last active
August 26, 2019 14:58
-
-
Save spikeekips/2bee3e29f22abac9caefeeb8d5e72af4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
################################################################## | |
# Copyright 2008 Spike^ekipS <spikeekips@gmail.com> | |
# | |
# This program is free software; you can redistribute it and/or modify | |
# it under the terms of the GNU General Public License as published by | |
# the Free Software Foundation; either version 2 of the License, or | |
# (at your option) any later version. | |
# | |
# This program is distributed in the hope that it will be useful, | |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
# GNU General Public License for more details. | |
# | |
# You should have received a copy of the GNU General Public License | |
# along with this program; if not, write to the Free Software | |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
################################################################## | |
set -e | |
set -x | |
cur=$(pwd) | |
commit=$(cd $cur/src/; git rev-parse --verify HEAD) | |
root=$(cd $(dirname ${BASH_SOURCE}); pwd)/logs/contest | |
t="$(date '+%Y%m%d%H%M%S')-${commit}" | |
log="${root}/${t}" | |
config=$(realpath $1) | |
if [ ! -f "${config}" ]; then | |
echo 'config file not found:' $config | |
exit 1 | |
fi | |
mkdir -p $log | |
rm -f "${root}/latest" | |
(cd "${root}"; ln -s $t latest) | |
cp $(cd $(dirname ${BASH_SOURCE}); pwd)/$0 $log/run.sh | |
cd $log | |
echo $@ > arguments.txt | |
echo $commit > $log/commit.txt | |
(cd $cur/src/; git diff -b > $log/diff.txt) | |
cp "${config}" config.yml | |
(cd $cur/src/contrib/contest; go build -race -o $log/contest *.go) | |
cleanup() { | |
nodes=$(cat all.log | grep '"message":"node created"' | jq -c '.node' | sed -e 's/"//g') | |
for i in $nodes | |
do | |
cat all.log | grep "\"node\":\"$i\"" > $i.log | |
done | |
for i in net sync syscall sched | |
do | |
go tool trace -pprof=$i trace.out > $i.prof || true | |
done | |
echo "exit $1" | |
exit $1 | |
} | |
trap cleanup SIGHUP SIGINT SIGTERM | |
./contest \ | |
run \ | |
$config \ | |
--log $(pwd) \ | |
--cpuprofile cpu.prof \ | |
--memprofile mem.prof \ | |
--trace trace.out \ | |
${@:2} \ | |
2> gc.log \ | |
| tee all.log | |
cleanup |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment