#!/usr/bin/env bash
#
# Example script to run from a cron job. Expects the
# following environment variables to be set:
#
#   RBX_ROOT - the root directory of the rubinius source
#   BASELINE - the name of the .yaml file of the baseline
#              benchmark results.
#
# To generate the baseline with MRI, run in RBX_ROOT
#
#  rake bench:dir DIR=benchmark/app VM=ruby GROUP=ruby-baseline
#
# This will create a file like:
#
#  benchmark/results/ruby-baseline-16-06-2009-2245.yaml
#
# Set BASELINE to that path (the real one).
#
# Finally, ensure 'rbx' is executable on the PATH, not just
# when in RBX_ROOT, because the benchmarks run in the
# benchmark/app dir.

cd $RBX_ROOT

# Run the benchmark without the jit
rake -q bench:dir DIR=benchmark/app VM=rbx GROUP=rbx-no-jit TIMEOUT=1200

# Run the benchmark with the jit
rake -q bench:dir DIR=benchmark/app VM='rbx -Xjit.enabled' GROUP=rbx-jit TIMEOUT=1200

# Generate the graph page
rake -q bench:results FIELD=median \
      TEMPLATE=benchmark/results/templates/rubinius.erb \
      BASELINE_ID='MRI 1.8.6' \
      BASELINE_MAX=2

