BRL-CAD
bu_timer.c
Go to the documentation of this file.
1 /* T E S T _ T I M E R . C
2  * BRL-CAD
3  *
4  * Copyright (c) 2011-2014 United States Government as represented by
5  * the U.S. Army Research Laboratory.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public License
9  * version 2.1 as published by the Free Software Foundation.
10  *
11  * This library is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this file; see the file named COPYING for more
18  * information.
19  */
20 
21 #include "common.h"
22 
23 #include <stdlib.h>
24 #include <stdio.h>
25 #include <string.h>
26 
27 #include "bu.h"
28 
29 
30 int
31 main(int argc, char **argv)
32 {
33  int64_t time1, time2;
34  int i = 0;
35  unsigned long counter = 1;
36 
37  if (argc > 1)
38  bu_exit(1, "ERROR: Unexpected parameter [%s]\n", argv[0]);
39 
40  time1 = bu_gettime();
41  while (i < 1.0e6) {
42  counter++;
43  time2 = bu_gettime();
44  i = time2 - time1;
45  }
46  bu_log("Called bu_gettime() %lu times\n", counter);
47  bu_log("Time delta: %d\n", i);
48  bu_log("time1: %lu\n", (unsigned long)time1);
49  bu_log("time2: %lu\n", (unsigned long)time2);
50 
51  return 0;
52 }
53 
54 
55 /** @} */
56 /*
57  * Local Variables:
58  * mode: C
59  * tab-width: 8
60  * indent-tabs-mode: t
61  * c-file-style: "stroustrup"
62  * End:
63  * ex: shiftwidth=4 tabstop=8
64  */
void bu_log(const char *,...) _BU_ATTR_PRINTF12
Definition: log.c:176
int main(int argc, char **argv)
Definition: bu_timer.c:31
Header file for the BRL-CAD common definitions.
void bu_exit(int status, const char *fmt,...) _BU_ATTR_NORETURN _BU_ATTR_PRINTF23
Definition: bomb.c:195
int64_t bu_gettime(void)
Definition: timer.c:42