ADT
aaron-thesis
arm-eh
ast-experimental
cleanup-dtors
deferred_resn
demangler
enum
forall-pointer-decay
jacob/cs343-translation
jenkins-sandbox
new-ast
new-ast-unique-expr
new-env
no_list
persistent-indexer
pthread-emulation
qualifiedEnum
resolv-new
with_gc
|
Last change
on this file since eb182b0 was 8cb6fcd, checked in by Thierry Delisle <tdelisle@…>, 8 years ago |
|
Refactored common code into bench.h
|
-
Property mode
set to
100644
|
|
File size:
740 bytes
|
| 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 | int main() {
|
|---|
| 27 | const unsigned int NoOfTimes = N;
|
|---|
| 28 | long long int StartTime, EndTime;
|
|---|
| 29 |
|
|---|
| 30 | GreatSuspender s;
|
|---|
| 31 |
|
|---|
| 32 | StartTime = Time();
|
|---|
| 33 | // for ( volatile unsigned int i = 0; i < NoOfTimes; i += 1 ) {
|
|---|
| 34 | // resume( this_coroutine() );
|
|---|
| 35 | // // resume( &s );
|
|---|
| 36 | // }
|
|---|
| 37 | resumer( &s, NoOfTimes );
|
|---|
| 38 | EndTime = Time();
|
|---|
| 39 |
|
|---|
| 40 | sout | ( EndTime - StartTime ) / NoOfTimes | endl;
|
|---|
| 41 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.