Changeset b4107c8 for benchmark/ctxswitch
- Timestamp:
- Jan 7, 2020, 3:50:56 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 580c11b
- Parents:
- 846c026
- Location:
- benchmark/ctxswitch
- Files:
-
- 3 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
benchmark/ctxswitch/JavaThread.java
r846c026 rb4107c8 26 26 static int x = 2; 27 27 28 static private final int NoOfTimes = Integer.parseInt("1000000");28 static private int times = Integer.parseInt("100000"); 29 29 30 30 public static void helper() { 31 for(int i = 1; i <= NoOfTimes; i += 1) {31 for(int i = 1; i <= times; i += 1) { 32 32 Thread.yield(); 33 33 } … … 37 37 helper(); 38 38 long end = System.nanoTime(); 39 System.out.println( (end - start) / NoOfTimes );39 System.out.println( (end - start) / times ); 40 40 } 41 41 public static void main(String[] args) throws InterruptedException { 42 for (int n = Integer.parseInt("5"); --n >= 0 ; ) { 42 if ( args.length > 2 ) System.exit( 1 ); 43 if ( args.length == 2 ) { times = Integer.parseInt(args[1]); } 44 45 for (int i = Integer.parseInt("5"); --i >= 0 ; ) { 43 46 InnerMain(); 44 Thread.sleep(2000); 47 Thread.sleep(2000); // 2 seconds 45 48 x = nextRandom(x); 46 49 } … … 48 51 } 49 52 } 53 54 // Local Variables: // 55 // tab-width: 4 // 56 // End: // -
benchmark/ctxswitch/cfa_cor.cfa
r846c026 rb4107c8 5 5 6 6 coroutine GreatSuspender {}; 7 8 void ?{}( GreatSuspender & this ) {9 prime(this);10 }11 12 7 void main( __attribute__((unused)) GreatSuspender & this ) { 13 while ( true ) {8 while ( true ) { 14 9 suspend(); 15 10 } 16 11 } 17 18 int main(int argc, char* argv[]) { 12 int main( int argc, char * argv[] ) { 13 BENCH_START() 19 14 GreatSuspender s; 20 21 15 BENCH( 22 for ( i; n) {16 for ( i; times ) { 23 17 resume( s ); 24 18 }, 25 19 result 26 20 ) 21 printf( "%g\n", result ); 22 } 27 23 28 printf("%g\n", result); 29 } 24 // Local Variables: // 25 // tab-width: 4 // 26 // End: // -
benchmark/ctxswitch/cfa_cor_then.cfa
r846c026 rb4107c8 18 18 } 19 19 20 int main(int argc, char* argv[]) { 20 int main( int argc, char * argv[] ) { 21 BENCH_START() 21 22 GreatSuspender s; 22 23 23 BENCH( 24 for ( i; n) {24 for ( i; times ) { 25 25 resume( s ); 26 26 }, 27 27 result 28 28 ) 29 printf( "%g\n", result ); 30 } 29 31 30 printf("%g\n", result); 31 } 32 // Local Variables: // 33 // tab-width: 4 // 34 // End: // -
benchmark/ctxswitch/cfa_gen.cfa
r846c026 rb4107c8 6 6 7 7 void comain( GreatSuspender * this ) { 8 9 8 if ( __builtin_expect(this->next != 0, 1) ) goto *(this->next); 9 this->next = &&s1; 10 10 for () { 11 11 return; 12 12 s1: ; 13 13 } 14 14 } 15 15 16 int main( int argc, char* argv[]) {17 GreatSuspender s = { 0 }; 18 16 int main( int argc, char * argv[] ) { 17 BENCH_START() 18 GreatSuspender s = { 0 }; 19 19 BENCH( 20 for ( i; n) {20 for ( i; times ) { 21 21 comain( &s ); 22 22 }, 23 23 result 24 24 ) 25 printf( "%g\n", result ); 26 } 25 27 26 printf("%g\n", result); 27 } 28 // Local Variables: // 29 // tab-width: 4 // 30 // End: // -
benchmark/ctxswitch/cfa_thrd.cfa
r846c026 rb4107c8 3 3 #include "bench.h" 4 4 5 int main(int argc, char* argv[]) { 5 int main( int argc, char * argv[] ) { 6 BENCH_START() 6 7 BENCH( 7 for ( i; n) {8 for ( i; times ) { 8 9 yield(); 9 10 }, 10 11 result 11 12 ) 13 printf( "%g\n", result ); 14 } 12 15 13 printf("%g\n", result); 14 } 16 // Local Variables: // 17 // tab-width: 4 // 18 // End: // -
benchmark/ctxswitch/cfa_thrd2.cfa
r846c026 rb4107c8 13 13 } 14 14 15 int main(int argc, char* argv[]) { 15 int main( int argc, char * argv[] ) { 16 BENCH_START() 16 17 Fibre f1; 17 18 BENCH( 18 for ( i; n) {19 for ( i; times ) { 19 20 yield(); 20 21 }, 21 22 result 22 23 ) 24 printf( "%g\n", result ); 25 done = true; 26 } 23 27 24 printf("%g\n", result); 25 done = true; 26 return 0; 27 } 28 // Local Variables: // 29 // tab-width: 4 // 30 // End: // -
benchmark/ctxswitch/goroutine.go
r846c026 rb4107c8 3 3 import ( 4 4 "fmt" 5 "time" 6 "flag" 5 7 "runtime" 6 "time"7 8 ) 8 9 … … 28 29 29 30 func main() { 30 const NoOfTimes = 1000000031 go ContextSwitch( NoOfTimes ) // context switch31 times := flag.Int( "times", 10000000, "loop iterations" ) 32 go ContextSwitch( *times ) // context switch 32 33 <- shake 33 34 } 35 36 // Local Variables: // 37 // tab-width: 4 // 38 // End: // -
benchmark/ctxswitch/kos_fibre.cpp
r846c026 rb4107c8 3 3 #include "bench.h" 4 4 5 int main(int argc, char* argv[]) { 5 int main( int argc, char * argv[] ) { 6 BENCH_START() 6 7 BENCH( 7 for (size_t i = 0; i < n; i++) {8 for (size_t i = 0; i < times; i++) { 8 9 Fibre::yield(); 9 10 }, 10 11 result 11 12 ) 12 printf("%g\n", result); 13 return 0; 13 printf( "%g\n", result ); 14 14 } 15 16 // Local Variables: // 17 // tab-width: 4 // 18 // End: // -
benchmark/ctxswitch/kos_fibre2.cpp
r846c026 rb4107c8 11 11 } 12 12 13 int main(int argc, char* argv[]) { 13 int main( int argc, char * argv[] ) { 14 BENCH_START() 14 15 Fibre* f1 = (new Fibre)->run(f1main); 15 16 BENCH( 16 for (size_t i = 0; i < n; i++) {17 for (size_t i = 0; i < times; i++) { 17 18 Fibre::yield(); 18 19 }, 19 20 result 20 21 ) 21 printf( "%g\n", result);22 printf( "%g\n", result ); 22 23 done = true; 23 24 Fibre::yield(); 24 25 f1->join(); 25 return 0;26 26 } 27 28 // Local Variables: // 29 // tab-width: 4 // 30 // End: // -
benchmark/ctxswitch/pthreads.c
r846c026 rb4107c8 6 6 #include "bench.h" 7 7 8 int main(int argc, char* argv[]) { 8 int main( int argc, char * argv[] ) { 9 BENCH_START() 9 10 BENCH( 10 for (size_t i = 0; i < n; i++) {11 for (size_t i = 0; i < times; i++) { 11 12 sched_yield(); 12 13 }, 13 14 result 14 15 ) 15 16 printf("%g\n", result); 16 printf( "%g\n", result ); 17 17 } -
benchmark/ctxswitch/upp_cor.cc
r846c026 rb4107c8 4 4 5 5 _Coroutine GreatSuspender { 6 public:7 GreatSuspender() {8 resume();9 }10 11 void do_resume() {12 resume();13 }14 private:15 6 void main() { 16 7 while( true ) { … … 18 9 } 19 10 } 11 public: 12 void do_resume() { 13 resume(); 14 } 20 15 }; 21 22 int main(int argc, char* argv[]) { 16 int main( int argc, char * argv[] ) { 17 BENCH_START() 23 18 GreatSuspender s; 24 25 19 BENCH( 26 for (size_t i = 0; i < n; i++) {20 for (size_t i = 0; i < times; i++) { 27 21 s.do_resume(); 28 22 }, 29 23 result 30 24 ) 25 printf( "%g\n", result ); 26 } 31 27 32 printf("%g\n", result); 33 } 28 // Local Variables: // 29 // tab-width: 4 // 30 // End: // -
benchmark/ctxswitch/upp_thrd.cc
r846c026 rb4107c8 3 3 #include "bench.h" 4 4 5 int main(int argc, char* argv[]) { 5 int main( int argc, char * argv[] ) { 6 BENCH_START() 6 7 BENCH( 7 for (size_t i = 0; i < n; i++) {8 for (size_t i = 0; i < times; i++) { 8 9 uThisTask().yield(); 9 10 }, 10 11 result 11 12 ) 13 printf( "%g\n", result ); 14 } 12 15 13 printf("%g\n", result); 14 } 16 // Local Variables: // 17 // tab-width: 4 // 18 // End: //
Note: See TracChangeset
for help on using the changeset viewer.