root/test/util/opal_timer.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. main

   1 /*
   2  * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
   3  *                         University Research and Technology
   4  *                         Corporation.  All rights reserved.
   5  * Copyright (c) 2004-2005 The University of Tennessee and The University
   6  *                         of Tennessee Research Foundation.  All rights
   7  *                         reserved.
   8  * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
   9  *                         University of Stuttgart.  All rights reserved.
  10  * Copyright (c) 2004-2005 The Regents of the University of California.
  11  *                         All rights reserved.
  12  * $COPYRIGHT$
  13  *
  14  * Additional copyrights may follow
  15  *
  16  * $HEADER$
  17  */
  18 
  19 #include "ompi_config.h"
  20 
  21 #include <unistd.h>
  22 
  23 #include "opal/runtime/opal.h"
  24 #include "opal/mca/timer/base/base.h"
  25 
  26 int
  27 main(int argc, char *argv[])
  28 {
  29     opal_timer_t start, end, diff;
  30 
  31     opal_init(&argc, &argv);
  32 
  33     printf("--> frequency: %llu\n", (unsigned long long) opal_timer_base_get_freq());
  34 
  35 #if OPAL_TIMER_CYCLE_SUPPORTED
  36     printf("--> cycle count\n");
  37     start = opal_timer_base_get_cycles();
  38     start = opal_timer_base_get_cycles();
  39     sleep(1);
  40     end = opal_timer_base_get_cycles();
  41     diff = end - start;
  42     printf("    Slept approximately %llu cycles, or %llu us\n",
  43            (unsigned long long) diff,
  44            (unsigned long long) ((diff * 1000000) / opal_timer_base_get_freq()));
  45 #else
  46     printf("--> cycle count not supported\n");
  47 #endif
  48 
  49 #if OPAL_TIMER_USEC_SUPPORTED
  50     printf("--> usecs\n");
  51     start = opal_timer_base_get_usec();
  52     sleep(1);
  53     end = opal_timer_base_get_usec();
  54     diff = end - start;
  55     printf("    Slept approximately %llu us\n", (unsigned long long) diff);
  56 #else
  57     printf("--> usec timer not supported\n");
  58 #endif
  59 
  60     opal_finalize();
  61 
  62     return 0;
  63 }

/* [<][>][^][v][top][bottom][index][help] */