Changeset 4069faad for benchmark/io
- Timestamp:
- May 1, 2020, 12:37:30 PM (5 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:
- d45ed83
- Parents:
- 9987d79
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified benchmark/io/readv.cfa ¶
r9987d79 r4069faad 30 30 unsigned long int buflen = 50; 31 31 32 cluster * the_cluster; 33 32 34 thread Reader {}; 35 void ?{}( Reader & this ) { 36 ((thread&)this){ "Reader Thread", *the_cluster }; 37 } 38 39 struct my_processor { 40 processor p; 41 }; 42 43 void ?{}( my_processor & this ) { 44 (this.p){ "I/O Processor", *the_cluster }; 45 } 46 33 47 void main( Reader & ) { 34 48 while(!__atomic_load_n(&run, __ATOMIC_RELAXED)) yield(); … … 38 52 39 53 while(__atomic_load_n(&run, __ATOMIC_RELAXED)) { 40 cfa_preadv2(fd, &iov, 1, 0, 0); 54 int r = cfa_preadv2(fd, &iov, 1, 0, 0); 55 if(r < 0) abort(strerror(-r)); 56 41 57 __atomic_fetch_add( &count, 1, __ATOMIC_SEQ_CST ); 42 58 } … … 44 60 45 61 int main(int argc, char * argv[]) { 46 #if !defined(__CFA_NO_STATISTICS__)47 print_stats_at_exit( *active_cluster() );48 #endif49 50 62 double duration = 5.0; 51 63 unsigned long int nthreads = 2; … … 117 129 } 118 130 119 intfd = open(__FILE__, 0);131 fd = open(__FILE__, 0); 120 132 if(fd < 0) { 121 133 fprintf(stderr, "Could not open source file\n"); … … 125 137 printf("Running %lu threads over %lu processors for %lf seconds\n", nthreads, nprocs, duration); 126 138 127 Time start, end;128 139 { 129 processor procs[nprocs - 1]; 140 Time start, end; 141 cluster cl = { "IO Cluster" }; 142 the_cluster = &cl; 143 #if !defined(__CFA_NO_STATISTICS__) 144 print_stats_at_exit( cl ); 145 #endif 130 146 { 131 Reader threads[nthreads]; 147 my_processor procs[nprocs]; 148 { 149 Reader threads[nthreads]; 132 150 133 printf("Starting\n"); 134 start = getTime(); 135 run = true; 136 do { 137 sleep(500`ms); 151 printf("Starting\n"); 152 start = getTime(); 153 run = true; 154 do { 155 sleep(500`ms); 156 end = getTime(); 157 } while( (end - start) < duration`s ); 158 run = false; 138 159 end = getTime(); 139 } while( (end - start) < duration`s ); 140 run = false; 141 end = getTime(); 160 printf("Done\n"); 161 } 142 162 } 163 printf("Took %ld ms\n", (end - start)`ms); 164 printf("Total reads: %'zu\n", count); 165 printf("Reads per second: %'lf\n", ((double)count) / (end - start)`s); 143 166 } 144 printf("Took %ld ms\n", (end - start)`ms);145 printf("Total reads: %'zu\n", count);146 printf("Reads per second: %'lf\n", ((double)count) / (end - start)`s);147 167 148 168 close(fd); 149 printf("Done\n");150 169 }
Note: See TracChangeset
for help on using the changeset viewer.