Ignore:
Timestamp:
Jan 7, 2020, 3:50:56 PM (5 years ago)
Author:
Peter A. Buhr <pabuhr@…>
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
Message:

update existing benchmarks for changes to bench.h, add new benchmarks in new programming languages

Location:
benchmark/ctxswitch
Files:
3 added
12 edited

Legend:

Unmodified
Added
Removed
  • benchmark/ctxswitch/JavaThread.java

    r846c026 rb4107c8  
    2626        static int x = 2;
    2727
    28         static private final int NoOfTimes = Integer.parseInt("1000000") ;
     28        static private int times = Integer.parseInt("100000");
    2929
    3030        public static void helper() {
    31                 for(int i = 1; i <= NoOfTimes; i += 1) {
     31                for(int i = 1; i <= times; i += 1) {
    3232                        Thread.yield();
    3333                }
     
    3737                helper();
    3838                long end = System.nanoTime();
    39                 System.out.println( (end - start) / NoOfTimes );
     39                System.out.println( (end - start) / times );
    4040        }
    4141        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 ; ) {
    4346                        InnerMain();
    44                         Thread.sleep(2000);     // 2 seconds
     47                        Thread.sleep(2000);     // 2 seconds
    4548                        x = nextRandom(x);
    4649                }
     
    4851        }
    4952}
     53
     54// Local Variables: //
     55// tab-width: 4 //
     56// End: //
  • benchmark/ctxswitch/cfa_cor.cfa

    r846c026 rb4107c8  
    55
    66coroutine GreatSuspender {};
    7 
    8 void ?{}( GreatSuspender & this ) {
    9         prime(this);
    10 }
    11 
    127void main( __attribute__((unused)) GreatSuspender & this ) {
    13         while( true ) {
     8        while ( true ) {
    149                suspend();
    1510        }
    1611}
    17 
    18 int main(int argc, char* argv[]) {
     12int main( int argc, char * argv[] ) {
     13        BENCH_START()
    1914        GreatSuspender s;
    20 
    2115        BENCH(
    22                 for ( i; n ) {
     16                for ( i; times ) {
    2317                        resume( s );
    2418                },
    2519                result
    2620        )
     21        printf( "%g\n", result );
     22}
    2723
    28         printf("%g\n", result);
    29 }
     24// Local Variables: //
     25// tab-width: 4 //
     26// End: //
  • benchmark/ctxswitch/cfa_cor_then.cfa

    r846c026 rb4107c8  
    1818}
    1919
    20 int main(int argc, char* argv[]) {
     20int main( int argc, char * argv[] ) {
     21        BENCH_START()
    2122        GreatSuspender s;
    22 
    2323        BENCH(
    24                 for ( i; n ) {
     24                for ( i; times ) {
    2525                        resume( s );
    2626                },
    2727                result
    2828        )
     29        printf( "%g\n", result );
     30}
    2931
    30         printf("%g\n", result);
    31 }
     32// Local Variables: //
     33// tab-width: 4 //
     34// End: //
  • benchmark/ctxswitch/cfa_gen.cfa

    r846c026 rb4107c8  
    66
    77void comain( GreatSuspender * this ) {
    8     if ( __builtin_expect(this->next != 0, 1) ) goto *(this->next);
    9     this->next = &&s1;
     8        if ( __builtin_expect(this->next != 0, 1) ) goto *(this->next);
     9        this->next = &&s1;
    1010        for () {
    11             return;
     11                return;
    1212          s1: ;
    1313        }
    1414}
    1515
    16 int main(int argc, char* argv[]) {
    17     GreatSuspender s = { 0 };
    18 
     16int main( int argc, char * argv[] ) {
     17        BENCH_START()
     18        GreatSuspender s = { 0 };
    1919        BENCH(
    20                 for ( i; n ) {
     20                for ( i; times ) {
    2121                        comain( &s );
    2222                },
    2323                result
    2424        )
     25        printf( "%g\n", result );
     26}
    2527
    26         printf("%g\n", result);
    27 }
     28// Local Variables: //
     29// tab-width: 4 //
     30// End: //
  • benchmark/ctxswitch/cfa_thrd.cfa

    r846c026 rb4107c8  
    33#include "bench.h"
    44
    5 int main(int argc, char* argv[]) {
     5int main( int argc, char * argv[] ) {
     6        BENCH_START()
    67        BENCH(
    7                 for ( i; n ) {
     8                for ( i; times ) {
    89                        yield();
    910                },
    1011                result
    1112        )
     13        printf( "%g\n", result );
     14}
    1215
    13         printf("%g\n", result);
    14 }
     16// Local Variables: //
     17// tab-width: 4 //
     18// End: //
  • benchmark/ctxswitch/cfa_thrd2.cfa

    r846c026 rb4107c8  
    1313}
    1414
    15 int main(int argc, char* argv[]) {
     15int main( int argc, char * argv[] ) {
     16        BENCH_START()
    1617        Fibre f1;
    1718        BENCH(
    18                 for ( i; n ) {
     19                for ( i; times ) {
    1920                        yield();
    2021                },
    2122                result
    2223        )
     24        printf( "%g\n", result );
     25        done = true;
     26}
    2327
    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  
    33import (
    44    "fmt"
     5    "time"
     6    "flag"
    57    "runtime"
    6     "time"
    78)
    89
     
    2829
    2930func main() {
    30         const NoOfTimes = 10000000
    31         go ContextSwitch( NoOfTimes )           // context switch
     31        times := flag.Int( "times", 10000000, "loop iterations" )
     32        go ContextSwitch( *times )              // context switch
    3233        <- shake
    3334}
     35
     36// Local Variables: //
     37// tab-width: 4 //
     38// End: //
  • benchmark/ctxswitch/kos_fibre.cpp

    r846c026 rb4107c8  
    33#include "bench.h"
    44
    5 int main(int argc, char* argv[]) {
     5int main( int argc, char * argv[] ) {
     6        BENCH_START()
    67        BENCH(
    7                 for (size_t i = 0; i < n; i++) {
     8                for (size_t i = 0; i < times; i++) {
    89                        Fibre::yield();
    910                },
    1011                result
    1112        )
    12         printf("%g\n", result);
    13         return 0;
     13        printf( "%g\n", result );
    1414}
     15
     16// Local Variables: //
     17// tab-width: 4 //
     18// End: //
  • benchmark/ctxswitch/kos_fibre2.cpp

    r846c026 rb4107c8  
    1111}
    1212
    13 int main(int argc, char* argv[]) {
     13int main( int argc, char * argv[] ) {
     14        BENCH_START()
    1415        Fibre* f1 = (new Fibre)->run(f1main);
    1516        BENCH(
    16                 for (size_t i = 0; i < n; i++) {
     17                for (size_t i = 0; i < times; i++) {
    1718                        Fibre::yield();
    1819                },
    1920                result
    2021        )
    21         printf("%g\n", result);
     22        printf( "%g\n", result );
    2223        done = true;
    2324        Fibre::yield();
    2425        f1->join();
    25         return 0;
    2626}
     27
     28// Local Variables: //
     29// tab-width: 4 //
     30// End: //
  • benchmark/ctxswitch/pthreads.c

    r846c026 rb4107c8  
    66#include "bench.h"
    77
    8 int main(int argc, char* argv[]) {
     8int main( int argc, char * argv[] ) {
     9        BENCH_START()
    910        BENCH(
    10                 for (size_t i = 0; i < n; i++) {
     11                for (size_t i = 0; i < times; i++) {
    1112                        sched_yield();
    1213                },
    1314                result
    1415        )
    15 
    16         printf("%g\n", result);
     16        printf( "%g\n", result );
    1717}
  • benchmark/ctxswitch/upp_cor.cc

    r846c026 rb4107c8  
    44
    55_Coroutine GreatSuspender {
    6 public:
    7         GreatSuspender() {
    8                 resume();
    9         }
    10 
    11         void do_resume() {
    12                 resume();
    13         }
    14 private:
    156        void main() {
    167                while( true ) {
     
    189                }
    1910        }
     11  public:
     12        void do_resume() {
     13                resume();
     14        }
    2015};
    21 
    22 int main(int argc, char* argv[]) {
     16int main( int argc, char * argv[] ) {
     17        BENCH_START()
    2318        GreatSuspender s;
    24 
    2519        BENCH(
    26                 for (size_t i = 0; i < n; i++) {
     20                for (size_t i = 0; i < times; i++) {
    2721                        s.do_resume();
    2822                },
    2923                result
    3024        )
     25        printf( "%g\n", result );
     26}
    3127
    32         printf("%g\n", result);
    33 }
     28// Local Variables: //
     29// tab-width: 4 //
     30// End: //
  • benchmark/ctxswitch/upp_thrd.cc

    r846c026 rb4107c8  
    33#include "bench.h"
    44
    5 int main(int argc, char* argv[]) {
     5int main( int argc, char * argv[] ) {
     6        BENCH_START()
    67        BENCH(
    7                 for (size_t i = 0; i < n; i++) {
     8                for (size_t i = 0; i < times; i++) {
    89                        uThisTask().yield();
    910                },
    1011                result
    1112        )
     13        printf( "%g\n", result );
     14}
    1215
    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.