#! /usr/bin/env bash

set -eo pipefail

ROOT=$( cd "$(dirname "$0")/.."; pwd )

TMP_DIR=$(mktemp -d)
echo "tmp dir: $TMP_DIR"

git clone --depth 1 -b master https://source.quilibrium.com/quilibrium/monorepo.git "$TMP_DIR/monorepo"
cd "$TMP_DIR/monorepo/kryptology"
go test -bench=. -short ./... > "$TMP_DIR/current-bench.log"

cd "$ROOT"
go test -bench=. -short ./... > "$TMP_DIR/new-bench.log"

cd "$ROOT"
go run cmd/benchcomp/main.go -current "$TMP_DIR/current-bench.log" -new "$TMP_DIR/new-bench.log"

rm -rf "$TMP_DIR"
