#!/bin/bash

set -eux

elisp_benchmarks=~/.emacs.d/elpa/elisp-benchmarks-1.1/elisp-benchmarks.el
emacs=~/Downloads/sources/emacs/src/emacs

sudo swapoff -a
sudo swapon -a

${emacs} -Q -batch -l ${elisp_benchmarks}           \
         -eval '(elisp-benchmarks-run "fibn\\.")' &

out=fibn-master.log

set +x
while true
do
    date +"%F-%T" >> ${out}
    ps o cputimes=,vsz=,rss=,args= $! >> ${out} || break
    free >> ${out}
    echo >> ${out}

    sleep 5
done
set -x
