#!/bin/bash
# A simple script to automate the collection of oprofile to gauge the
# the performance of oprofile infrastructure
#
# This script has to be run as root.
# 
# Usage: get_oprof_data /patch/to/vmlinux

do_experiment()
{

echo
echo "Doing experiment for $2"
echo

#clear out old profiling data
opcontrol --reset

opcontrol --setup --event=default --vmlinux=$1
/sbin/insmod $2.ko
opcontrol --start
/sbin/rmmod $2
opcontrol --shutdown

#generate output
# limit to things that have more 1% or more of the samples
opreport $1 -l -t 1
}

do_experiment $1 kprobe-timing
do_experiment $1 jprobe-timing
