C Interface 
#include <papi.h> 
int PAPI_stop_counters(long_long *values, int array_len); 
Fortran Interface 
PAPIF_stop_counters(C_LONG_LONG(*) values, C_INT array_len, C_INT check) 
#include fpapi.h 
  int Events[2] = { PAPI_TOT_CYC, PAPI_TOT_INS };
  long_long values[2];
  int num_hwcntrs = 0;
        
  if ((num_hwcntrs = PAPI_num_counters()) < PAPI_OK)
    handle_error(1);
  if (num_hwcntrs > 2)
    num_hwcntrs = 2;
  /* Start counting events */
  if (PAPI_start_counters(Events, num_hwcntrs) != PAPI_OK)
    handle_error(1);
  your_slow_code();
  /* Stop counting events */
  if (PAPI_stop_counters(values, num_hwcntrs) != PAPI_OK)
    handle_error(1);