Changeset bd951f7
- Timestamp:
- May 5, 2017, 11:03:29 AM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 43426d4, 4f9636f
- Parents:
- e0b8ccd5
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/benchmark/csv-data.c
re0b8ccd5 rbd951f7 1 1 #include <fstream> 2 #include <monitor> 2 3 #include <stdlib> 3 4 #include <thread> … … 28 29 #endif 29 30 30 31 31 //----------------------------------------------------------------------------- 32 // coroutine context switch 32 33 long long int measure_coroutine() { 33 34 const unsigned int NoOfTimes = N; … … 47 48 } 48 49 50 //----------------------------------------------------------------------------- 51 // thread context switch 49 52 long long int measure_thread() { 50 53 const unsigned int NoOfTimes = N; … … 60 63 } 61 64 65 //----------------------------------------------------------------------------- 66 // single monitor entry 67 monitor mon_t {}; 68 void dummy( mon_t * mutex m ) {} 69 70 long long int measure_1_monitor_entry() { 71 const unsigned int NoOfTimes = N; 72 long long int StartTime, EndTime; 73 mon_t mon; 74 75 StartTime = Time(); 76 for ( volatile unsigned int i = 0; i < NoOfTimes; i += 1 ) { 77 dummy( &mon ); 78 } 79 EndTime = Time(); 80 81 return ( EndTime - StartTime ) / NoOfTimes; 82 } 83 84 //----------------------------------------------------------------------------- 85 // multi monitor entry 86 void dummy( mon_t * mutex m1, mon_t * mutex m2 ) {} 87 88 long long int measure_2_monitor_entry() { 89 const unsigned int NoOfTimes = N; 90 long long int StartTime, EndTime; 91 mon_t mon1, mon2; 92 93 StartTime = Time(); 94 for ( volatile unsigned int i = 0; i < NoOfTimes; i += 1 ) { 95 dummy( &mon1, &mon2 ); 96 } 97 EndTime = Time(); 98 99 return ( EndTime - StartTime ) / NoOfTimes; 100 } 101 62 102 int main() 63 103 { 64 sout | time(NULL) | ',' | measure_coroutine() | ',' | measure_thread() | endl; 104 sout | time(NULL) | ','; 105 sout | measure_coroutine() | ','; 106 sout | measure_thread() | ','; 107 sout | measure_1_monitor_entry() | ','; 108 sout | measure_2_monitor_entry() | endl; 65 109 }
Note: See TracChangeset
for help on using the changeset viewer.