C Interface
#include <papi.h>
int PAPI_start(int EventSet);
int PAPI_stop(int EventSet, long_long *values);
Fortran Interface
#include fpapi.h
PAPIF_start(C_INT EventSet, C_INT check)
PAPIF_stop(C_INT EventSet, C_LONG_LONG(*) values, C_INT check)
if (PAPI_create_eventset(&EventSet) != PAPI_OK)
handle_error(1);
/* Add Total Instructions Executed to our EventSet */
if (PAPI_add_event(EventSet, PAPI_TOT_INS) != PAPI_OK)
handle_error(1);
/* Start counting */
if (PAPI_start(EventSet) != PAPI_OK)
handle_error(1);
poorly_tuned_function();
if (PAPI_stop(EventSet, values) != PAPI_OK)
handle_error(1);
printf("%lld\n",values[0]);