source: src/benchmark/bench.h@ b96ec83

ADT arm-eh ast-experimental cleanup-dtors enum forall-pointer-decay jacob/cs343-translation jenkins-sandbox new-ast new-ast-unique-expr pthread-emulation qualifiedEnum
Last change on this file since b96ec83 was dbe7756, checked in by Thierry Delisle <tdelisle@…>, 8 years ago

bench.h now compiles in C and C++

  • Property mode set to 100644
File size: 632 bytes
RevLine 
[8cb6fcd]1#pragma once
2
[dbe7756]3#ifdef __CFORALL__
[8cb6fcd]4extern "C" {
[dbe7756]5#endif
[8cb6fcd]6 #include <unistd.h> // sysconf
7 #include <sys/times.h> // times
8 #include <time.h>
[dbe7756]9#ifdef __CFORALL__
[8cb6fcd]10}
[dbe7756]11#endif
12
[8cb6fcd]13
[dbe7756]14static inline unsigned long long int Time() {
15 struct timespec ts;
[8cb6fcd]16 clock_gettime(
17#if defined( __linux__ )
18 CLOCK_THREAD_CPUTIME_ID,
19#elif defined( __freebsd__ )
20 CLOCK_PROF,
21#elif defined( __solaris__ )
22 CLOCK_HIGHRES,
23#else
24 #error uC++ : internal error, unsupported architecture
25#endif
26 &ts );
27 return 1000000000LL * ts.tv_sec + ts.tv_nsec;
28} // Time
29
30#ifndef N
31#define N 10000000
[7286a40]32#endif
33
34unsigned int default_preemption() {
35 return 0;
36}
Note: See TracBrowser for help on using the repository browser.