pmm  1.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
timer_test.c
Go to the documentation of this file.
1 #include <math.h>
2 #include <stdlib.h>
3 #include <stdio.h>
4 #include "pmm_util.h"
5 
6 #define NARGS 1
7 
8 int main(int argc, char **argv) {
9 
10 
11  /* declare variables */
12  double a;
13  double b;
14  double c;
15  double i;
16 
17  /* parse arguments */
18  if(argc != NARGS+1) {
19  return PMM_EXIT_ARGFAIL;
20  }
21  if(sscanf(argv[1], "%lf", &i) == 0) {
22  return PMM_EXIT_ARGPARSEFAIL;
23  }
24 
25  printf("%f\n", i);
26 
27  /* initialise data */
28  a = M_PI;
29  b = M_E;
30 
31  /* initialise timer */
33 
34  /* start timer */
36 
37  /* execute routine */
38  while(i>0.0) {
39  c = a * b;
40  i = i - 1.0;
41  }
42 
43  /* stop timer */
45 
46  /* get timing result */
48 
49  /* destroy timer */
51 
52  return PMM_EXIT_SUCCESS;
53 }