Changeset 01c6256 for benchmark/benchcltr.hfa
- Timestamp:
- Aug 11, 2020, 1:54:30 PM (4 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 9f1c286
- Parents:
- e857743
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
benchmark/benchcltr.hfa
re857743 r01c6256 1 1 #pragma once 2 #include <assert.h> 3 #include <stdint.h> 2 4 3 #include <assert.h> 4 #include <kernel.hfa> 5 #include <thread.hfa> 6 #include <stats.hfa> 5 #ifdef __cforall 6 #include <kernel.hfa> 7 #include <thread.hfa> 8 #include <stats.hfa> 9 #else 10 #include <time.h> // timespec 11 #include <sys/time.h> // timeval 12 13 enum { TIMEGRAN = 1000000000LL }; // nanosecond granularity, except for timeval 14 #endif 7 15 8 16 #define BENCH_OPT_SHORT "d:p:t:SPV" … … 55 63 bool procstats = false; 56 64 bool viewhalts = false; 65 66 #ifdef __cforall 57 67 struct cluster * the_benchmark_cluster = 0p; 58 68 struct BenchCluster { … … 60 70 }; 61 71 62 void ?{}( BenchCluster & this, int flags, int stats ) {63 (this.self){ "Benchmark Cluster", flags };72 void ?{}( BenchCluster & this, int num_io, const io_context_params & io_params, int stats ) { 73 (this.self){ "Benchmark Cluster", num_io, io_params }; 64 74 65 75 assert( the_benchmark_cluster == 0p ); … … 105 115 } 106 116 } 117 #else 118 uint64_t getTimeNsec() { 119 timespec curr; 120 clock_gettime( CLOCK_REALTIME, &curr ); 121 return (int64_t)curr.tv_sec * TIMEGRAN + curr.tv_nsec; 122 } 123 124 uint64_t to_miliseconds( uint64_t durtn ) { return durtn / (TIMEGRAN / 1000LL); } 125 double to_fseconds(uint64_t durtn ) { return durtn / (double)TIMEGRAN; } 126 uint64_t from_fseconds(double sec) { return sec * TIMEGRAN; } 127 128 129 void wait_duration(double duration, uint64_t & start, uint64_t & end, bool is_tty) { 130 for(;;) { 131 usleep(100000); 132 end = getTimeNsec(); 133 uint64_t delta = end - start; 134 /*if(is_tty)*/ { 135 printf(" %.1f\r", to_fseconds(delta)); 136 fflush(stdout); 137 } 138 if( delta >= from_fseconds(duration) ) { 139 break; 140 } 141 } 142 } 143 #endif 144 107 145 108 146 void bench_usage( char * argv [] ) {
Note: See TracChangeset
for help on using the changeset viewer.