ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change
on this file since 8cb6fcd was
8cb6fcd,
checked in by Thierry Delisle <tdelisle@…>, 7 years ago
|
Refactored common code into bench.h
|
-
Property mode set to
100644
|
File size:
1.1 KB
|
Line | |
---|
1 | #include <fstream> |
---|
2 | #include <stdlib> |
---|
3 | #include <thread> |
---|
4 | |
---|
5 | #include "bench.h" |
---|
6 | |
---|
7 | coroutine GreatSuspender {}; |
---|
8 | |
---|
9 | void ?{}( GreatSuspender * this ) { |
---|
10 | prime(this); |
---|
11 | } |
---|
12 | |
---|
13 | void main( GreatSuspender * this ) |
---|
14 | { |
---|
15 | while( true ) { |
---|
16 | suspend(); |
---|
17 | } |
---|
18 | } |
---|
19 | |
---|
20 | void resumer( GreatSuspender * this, const unsigned int NoOfTimes ) { |
---|
21 | for ( volatile unsigned int i = 0; i < NoOfTimes; i += 1 ) { |
---|
22 | resume( this ); |
---|
23 | } |
---|
24 | } |
---|
25 | |
---|
26 | #ifndef N |
---|
27 | #define N 100000000 |
---|
28 | #endif |
---|
29 | |
---|
30 | |
---|
31 | |
---|
32 | long long int measure_coroutine() { |
---|
33 | const unsigned int NoOfTimes = N; |
---|
34 | long long int StartTime, EndTime; |
---|
35 | |
---|
36 | GreatSuspender s; |
---|
37 | |
---|
38 | StartTime = Time(); |
---|
39 | // for ( volatile unsigned int i = 0; i < NoOfTimes; i += 1 ) { |
---|
40 | // resume( this_coroutine() ); |
---|
41 | // // resume( &s ); |
---|
42 | // } |
---|
43 | resumer( &s, NoOfTimes ); |
---|
44 | EndTime = Time(); |
---|
45 | |
---|
46 | return ( EndTime - StartTime ) / NoOfTimes; |
---|
47 | } |
---|
48 | |
---|
49 | long long int measure_thread() { |
---|
50 | const unsigned int NoOfTimes = N; |
---|
51 | long long int StartTime, EndTime; |
---|
52 | |
---|
53 | StartTime = Time(); |
---|
54 | for ( volatile unsigned int i = 0; i < NoOfTimes; i += 1 ) { |
---|
55 | yield(); |
---|
56 | } |
---|
57 | EndTime = Time(); |
---|
58 | |
---|
59 | return ( EndTime - StartTime ) / NoOfTimes; |
---|
60 | } |
---|
61 | |
---|
62 | int main() |
---|
63 | { |
---|
64 | sout | time(NULL) | ',' | measure_coroutine() | ',' | measure_thread() | endl; |
---|
65 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.