#!/usr/bin/env bash
set -euo pipefail
export TZ=UTC
out=${1:-out}
mkdir -p "$out"
go version > "$out/environment.txt"
go env GOOS GOARCH CGO_ENABLED >> "$out/environment.txt"
go test -v . > "$out/test.txt"
go test -race . >> "$out/test.txt"
go vet . >> "$out/test.txt"
go build -o "$out/lab" .
"$out/lab" "$out" > "$out/run.txt"
for p in cpu heap allocs goroutine block mutex threadcreate; do
 go tool pprof -top -nodecount=8 "$out/lab" "$out/$p.pb.gz" > "$out/$p-top.txt"
done
