Changeset 58fe85a for benchmark


Ignore:
Timestamp:
Jan 7, 2021, 3:27:00 PM (5 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
2b4daf2, 64aeca0
Parents:
3c64c668 (diff), eef8dfb (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' into park_unpark

Location:
benchmark
Files:
41 added
1 deleted
10 edited

Legend:

Unmodified
Added
Removed
  • benchmark/Makefile.am

    r3c64c668 r58fe85a  
    1111## Created On       : Sun May 31 09:08:15 2015
    1212## Last Modified By : Peter A. Buhr
    13 ## Last Modified On : Sat Jan 25 09:20:44 2020
    14 ## Update Count     : 255
     13## Last Modified On : Tue Mar 10 11:41:18 2020
     14## Update Count     : 258
    1515###############################################################################
    1616
     
    1919
    2020# applies to both programs
    21 include $(top_srcdir)/src/cfa.make
     21include $(top_srcdir)/tools/build/cfa.make
    2222
    2323AM_CFLAGS = -O2 -Wall -Wextra -I$(srcdir) -lrt -pthread # -Werror
     
    6666# Dummy hack tricks
    6767EXTRA_PROGRAMS = dummy # build but do not install
    68 dummy_SOURCES = dummyC.c dummyCXX.cpp
     68nodist_dummy_SOURCES = dummyC.c dummyCXX.cpp
    6969
    7070dummyC.c:
     
    8080## =========================================================================================================
    8181
    82 all : basic$(EXEEXT) ctxswitch$(EXEEXT) mutex$(EXEEXT) schedint$(EXEEXT) schedext$(EXEEXT) creation$(EXEEXT)
     82# all is used by make dist so ignore it
     83all:
     84
     85all-bench : basic$(EXEEXT) ctxswitch$(EXEEXT) mutex$(EXEEXT) schedint$(EXEEXT) schedext$(EXEEXT) creation$(EXEEXT)
    8386
    8487basic_loop_DURATION = 15000000000
     
    108111creation_cfa_coroutine_DURATION = 100000000
    109112creation_cfa_coroutine_eager_DURATION = 10000000
     113creation_cfa_generator_DURATION = 1000000000
    110114creation_upp_coroutine_DURATION = ${creation_cfa_coroutine_eager_DURATION}
    111 creation_cfa_thread_DURATION = 10000000
    112 creation_upp_thread_DURATION = ${creation_cfa_thread_DURATION}
    113115creation_DURATION = 10000000
    114116
     
    144146
    145147cleancsv:
    146         rm -f compile.csv basic.csv ctxswitch.csv mutex.csv scheduling.csv
     148        rm -f compile.csv basic.csv ctxswitch.csv mutex.csv schedint.csv
    147149
    148150jenkins$(EXEEXT): cleancsv
     
    155157        +make mutex.csv
    156158        -+make mutex.diff.csv
    157         +make scheduling.csv
    158         -+make scheduling.diff.csv
     159        +make schedint.csv
     160        -+make schedint.diff.csv
    159161@DOifskipcompile@
    160162        cat compile.csv
     
    165167        cat mutex.csv
    166168        -cat mutex.diff.csv
    167         cat scheduling.csv
    168         -cat scheduling.diff.csv
     169        cat schedint.csv
     170        -cat schedint.diff.csv
    169171
    170172compile.csv:
     
    196198        $(srcdir)/fixcsv.sh $@
    197199
    198 scheduling.csv:
     200schedint.csv:
    199201        echo "building $@"
    200202        echo "schedint-1,schedint-2,schedext-1,schedext-2" > $@
     
    287289ctxswitch-python_coroutine$(EXEEXT):
    288290        $(BENCH_V_PY)echo "#!/bin/sh" > a.out
    289         echo "python3.7 $(srcdir)/ctxswitch/python_cor.py" >> a.out
     291        echo "python3 $(srcdir)/ctxswitch/python_cor.py \"$$""@\"" >> a.out
    290292        chmod a+x a.out
    291293
    292294ctxswitch-nodejs_coroutine$(EXEEXT):
    293295        $(BENCH_V_NODEJS)echo "#!/bin/sh" > a.out
    294         echo "nodejs $(srcdir)/ctxswitch/node_cor.js" >> a.out
     296        echo "nodejs $(srcdir)/ctxswitch/node_cor.js \"$$""@\"" >> a.out
    295297        chmod a+x a.out
    296298
    297299ctxswitch-nodejs_await$(EXEEXT):
    298300        $(BENCH_V_NODEJS)echo "#!/bin/sh" > a.out
    299         echo "nodejs $(srcdir)/ctxswitch/node_await.js" >> a.out
     301        echo "nodejs $(srcdir)/ctxswitch/node_await.js \"$$""@\"" >> a.out
    300302        chmod a+x a.out
    301303
     
    309311        $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/ctxswitch/JavaThread.java
    310312        echo "#!/bin/sh" > a.out
    311         echo "java JavaThread" >> a.out
     313        echo "java JavaThread \"$$""@\"" >> a.out
    312314        chmod a+x a.out
    313315
     
    351353        $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/mutex/JavaThread.java
    352354        echo "#!/bin/sh" > a.out
    353         echo "java JavaThread" >> a.out
     355        echo "java JavaThread \"$$""@\"" >> a.out
    354356        chmod a+x a.out
    355357
     
    383385        $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/schedint/JavaThread.java
    384386        echo "#!/bin/sh" > a.out
    385         echo "java JavaThread" >> a.out
     387        echo "java JavaThread \"$$""@\"" >> a.out
    386388        chmod a+x a.out
    387389
     
    450452creation-python_coroutine$(EXEEXT):
    451453        $(BENCH_V_PY)echo "#!/bin/sh" > a.out
    452         echo "python3.7 $(srcdir)/creation/python_cor.py" >> a.out
     454        echo "python3 $(srcdir)/creation/python_cor.py \"$$""@\"" >> a.out
    453455        chmod a+x a.out
    454456
    455457creation-nodejs_coroutine$(EXEEXT):
    456458        $(BENCH_V_NODEJS)echo "#!/bin/sh" > a.out
    457         echo "nodejs $(srcdir)/creation/node_cor.js" >> a.out
     459        echo "nodejs $(srcdir)/creation/node_cor.js \"$$""@\"" >> a.out
    458460        chmod a+x a.out
    459461
     
    467469        $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/creation/JavaThread.java
    468470        echo "#!/bin/sh" > a.out
    469         echo "java JavaThread" >> a.out
     471        echo "java JavaThread \"$$""@\"" >> a.out
    470472        chmod a+x a.out
    471473
     
    475477## =========================================================================================================
    476478
    477 compile$(EXEEXT) :              \
     479bcompile$(EXEEXT) :             \
    478480        compile-array.make      \
    479481        compile-attributes.make \
     
    488490
    489491compile-array$(EXEEXT):
    490         $(CFACOMPILE) -fsyntax-only -w $(testdir)/array.cfa
     492        $(CFACOMPILE) -DNO_COMPILED_PRAGMA -fsyntax-only -w $(testdir)/array.cfa
    491493
    492494compile-attributes$(EXEEXT):
    493         $(CFACOMPILE) -fsyntax-only -w $(testdir)/attributes.cfa
     495        $(CFACOMPILE) -DNO_COMPILED_PRAGMA -fsyntax-only -w $(testdir)/attributes.cfa
    494496
    495497compile-empty$(EXEEXT):
    496         $(CFACOMPILE) -fsyntax-only -w $(srcdir)/compile/empty.cfa
     498        $(CFACOMPILE) -DNO_COMPILED_PRAGMA -fsyntax-only -w $(srcdir)/compile/empty.cfa
    497499
    498500compile-expression$(EXEEXT):
    499         $(CFACOMPILE) -fsyntax-only -w $(testdir)/expression.cfa
     501        $(CFACOMPILE) -DNO_COMPILED_PRAGMA -fsyntax-only -w $(testdir)/expression.cfa
    500502
    501503compile-io$(EXEEXT):
    502         $(CFACOMPILE) -fsyntax-only -w $(testdir)/io1.cfa
     504        $(CFACOMPILE) -DNO_COMPILED_PRAGMA -fsyntax-only -w $(testdir)/io1.cfa
    503505
    504506compile-monitor$(EXEEXT):
    505         $(CFACOMPILE) -fsyntax-only -w $(testdir)/concurrent/monitor.cfa
     507        $(CFACOMPILE) -DNO_COMPILED_PRAGMA -fsyntax-only -w $(testdir)/concurrent/monitor.cfa
    506508
    507509compile-operators$(EXEEXT):
    508         $(CFACOMPILE) -fsyntax-only -w $(testdir)/operators.cfa
     510        $(CFACOMPILE) -DNO_COMPILED_PRAGMA -fsyntax-only -w $(testdir)/operators.cfa
    509511
    510512compile-thread$(EXEEXT):
    511         $(CFACOMPILE) -fsyntax-only -w $(testdir)/concurrent/thread.cfa
     513        $(CFACOMPILE) -DNO_COMPILED_PRAGMA -fsyntax-only -w $(testdir)/concurrent/thread.cfa
    512514
    513515compile-typeof$(EXEEXT):
    514         $(CFACOMPILE) -fsyntax-only -w $(testdir)/typeof.cfa
     516        $(CFACOMPILE) -DNO_COMPILED_PRAGMA -fsyntax-only -w $(testdir)/typeof.cfa
    515517
    516518## =========================================================================================================
     
    520522size-cfa$(EXEEXT):
    521523        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/size/size.cfa
     524
     525## =========================================================================================================
     526
     527%-tokio$(EXEEXT): $(srcdir)/readyQ/%.rs $(srcdir)/bench.rs
     528        cd $(builddir) && cargo build --release
     529        cp $(builddir)/target/release/$(basename $@) $@
  • benchmark/creation/JavaThread.java

    r3c64c668 r58fe85a  
    11public class JavaThread {
    22        // Simplistic low-quality Marsaglia Shift-XOR pseudo-random number generator.
    3         // Bijective   
     3        // Bijective
    44        // Cycle length for non-zero values is 4G-1.
    55        // 0 is absorbing and should be avoided -- fixed point.
    66        // The returned value is typically masked to produce a positive value.
    7         static volatile int Ticket = 0 ; 
     7        static volatile int Ticket = 0 ;
    88
    99        private static int nextRandom (int x) {
    10                 if (x == 0) { 
     10                if (x == 0) {
    1111                        // reseed the PRNG
    12                         // Ticket is accessed infrequently and does not constitute a coherence hot-spot. 
    13                         // Note that we use a non-atomic racy increment -- the race is rare and benign. 
    14                         // If the race is a concern switch to an AtomicInteger. 
    15                         // In addition accesses to the RW volatile global "Ticket"  variable are not 
    16                         // (readily) predictable at compile-time so the JIT will not be able to elide 
    17                         // nextRandom() invocations. 
    18                         x = ++Ticket ; 
    19                         if (x == 0) x = 1 ; 
     12                        // Ticket is accessed infrequently and does not constitute a coherence hot-spot.
     13                        // Note that we use a non-atomic racy increment -- the race is rare and benign.
     14                        // If the race is a concern switch to an AtomicInteger.
     15                        // In addition accesses to the RW volatile global "Ticket"  variable are not
     16                        // (readily) predictable at compile-time so the JIT will not be able to elide
     17                        // nextRandom() invocations.
     18                        x = ++Ticket ;
     19                        if (x == 0) x = 1 ;
    2020                }
    2121                x ^= x << 6;
    2222                x ^= x >>> 21;
    2323                x ^= x << 7;
    24                 return x ;   
     24                return x ;
    2525        }
    2626        static int x = 2;
    2727
    28         static private int times = Integer.parseInt("10000") ;
     28        static private long times = Long.parseLong("10000") ;
    2929
    3030        public static class MyThread extends Thread {
     
    3333        }
    3434        public static void helper() throws InterruptedException {
    35                 for(int i = 1; i <= times; i += 1) {
     35                for(long i = 1; i <= times; i += 1) {
    3636                        MyThread m = new MyThread();
    3737                        x = nextRandom( x );
     
    4747        }
    4848        public static void main(String[] args) throws InterruptedException {
    49                 if ( args.length > 2 ) System.exit( 1 );
    50                 if ( args.length == 2 ) { times = Integer.parseInt(args[1]); }
     49                if ( args.length > 1 ) System.exit( 1 );
     50                if ( args.length == 1 ) { times = Long.parseLong(args[0]); }
    5151
    52                 for (int i = Integer.parseInt("5"); --i >= 0 ; ) { 
     52                for (int i = Integer.parseInt("5"); --i >= 0 ; ) {
    5353                        InnerMain();
    5454                        Thread.sleep(2000);             // 2 seconds
  • benchmark/creation/cfa_gen.cfa

    r3c64c668 r58fe85a  
    1 #include "bench.h"
     1#include "../bench.h"
    22
    3 struct C {
     3generator G {
    44        volatile int restart; // ensure compiler does not optimize away all the code
    55};
    6 void ?{}( C & c ) { c.restart = 0; }
    7 void main( C & ) {}
     6void ?{}( G & g ) { g.restart = 0; }
     7void main( G & ) {}
    88
    99int main( int argc, char * argv[] ) {
     
    1111        BENCH(
    1212                for ( times ) {
    13                          C c;
     13                         G g;
    1414                },
    1515                result
  • benchmark/ctxswitch/JavaThread.java

    r3c64c668 r58fe85a  
    11public class JavaThread {
    22        // Simplistic low-quality Marsaglia Shift-XOR pseudo-random number generator.
    3         // Bijective   
     3        // Bijective
    44        // Cycle length for non-zero values is 4G-1.
    55        // 0 is absorbing and should be avoided -- fixed point.
    66        // The returned value is typically masked to produce a positive value.
    7         static volatile int Ticket = 0 ; 
     7        static volatile int Ticket = 0 ;
    88
    99        private static int nextRandom (int x) {
    10                 if (x == 0) { 
     10                if (x == 0) {
    1111                        // reseed the PRNG
    12                         // Ticket is accessed infrequently and does not constitute a coherence hot-spot. 
    13                         // Note that we use a non-atomic racy increment -- the race is rare and benign. 
    14                         // If the race is a concern switch to an AtomicInteger. 
    15                         // In addition accesses to the RW volatile global "Ticket"  variable are not 
    16                         // (readily) predictable at compile-time so the JIT will not be able to elide 
    17                         // nextRandom() invocations. 
    18                         x = ++Ticket ; 
    19                         if (x == 0) x = 1 ; 
     12                        // Ticket is accessed infrequently and does not constitute a coherence hot-spot.
     13                        // Note that we use a non-atomic racy increment -- the race is rare and benign.
     14                        // If the race is a concern switch to an AtomicInteger.
     15                        // In addition accesses to the RW volatile global "Ticket"  variable are not
     16                        // (readily) predictable at compile-time so the JIT will not be able to elide
     17                        // nextRandom() invocations.
     18                        x = ++Ticket ;
     19                        if (x == 0) x = 1 ;
    2020                }
    2121                x ^= x << 6;
    2222                x ^= x >>> 21;
    2323                x ^= x << 7;
    24                 return x ;   
     24                return x ;
    2525        }
    2626        static int x = 2;
    2727
    28         static private int times = Integer.parseInt("100000");
     28        static private long times = Long.parseLong("100000");
    2929
    3030        public static void helper() {
    31                 for(int i = 1; i <= times; i += 1) {
     31                for(long i = 1; i <= times; i += 1) {
    3232                        Thread.yield();
    3333                }
     
    4040        }
    4141        public static void main(String[] args) throws InterruptedException {
    42                 if ( args.length > 2 ) System.exit( 1 );
    43                 if ( args.length == 2 ) { times = Integer.parseInt(args[1]); }
     42                if ( args.length > 1 ) System.exit( 1 );
     43                if ( args.length == 1 ) { times = Long.parseLong(args[0]); }
    4444
    4545                for (int i = Integer.parseInt("5"); --i >= 0 ; ) {
  • benchmark/ctxswitch/cfa_cor.cfa

    r3c64c668 r58fe85a  
    22#include <thread.hfa>
    33
    4 #include "bench.h"
     4#include "../bench.h"
    55
    6 coroutine C {} c;
     6coroutine C {};
    77void main( __attribute__((unused)) C & ) {
    8         while () {
    9                 suspend();
     8        for () {
     9                suspend;
    1010        }
    1111}
    1212int main( int argc, char * argv[] ) {
     13        C c;
    1314        BENCH_START()
    1415        BENCH(
  • benchmark/ctxswitch/cfa_gen.cfa

    r3c64c668 r58fe85a  
    11#include "../bench.h"
    22
    3 typedef struct {
    4         void * next;
    5 } C;
    6 
    7 void comain( C * c ) {
    8         if ( __builtin_expect(c->next != 0, 1) ) goto *(c->next);
    9         c->next = &&s1;
     3generator G {};
     4void main( G & ) {
    105        for () {
    11                 return;
    12           s1: ;
     6                suspend;
    137        }
    148}
    159
    1610int main( int argc, char * argv[] ) {
     11        G g;
    1712        BENCH_START()
    18         C c = { 0 };
    1913        BENCH(
    2014                for ( times ) {
    21                         comain( &c );
     15                        resume( g );
    2216                },
    2317                result
  • benchmark/exclude

    r3c64c668 r58fe85a  
    1010interrupt_linux.c
    1111exclude
     12io
    1213Monitor.c
  • benchmark/mutex/JavaThread.java

    r3c64c668 r58fe85a  
    11public class JavaThread {
    22        // Simplistic low-quality Marsaglia Shift-XOR pseudo-random number generator.
    3         // Bijective   
     3        // Bijective
    44        // Cycle length for non-zero values is 4G-1.
    55        // 0 is absorbing and should be avoided -- fixed point.
    66        // The returned value is typically masked to produce a positive value.
    7         static volatile int Ticket = 0 ; 
     7        static volatile int Ticket = 0 ;
    88
    99        private static int nextRandom (int x) {
    10                 if (x == 0) { 
     10                if (x == 0) {
    1111                        // reseed the PRNG
    12                         // Ticket is accessed infrequently and does not constitute a coherence hot-spot. 
    13                         // Note that we use a non-atomic racy increment -- the race is rare and benign. 
    14                         // If the race is a concern switch to an AtomicInteger. 
    15                         // In addition accesses to the RW volatile global "Ticket"  variable are not 
    16                         // (readily) predictable at compile-time so the JIT will not be able to elide 
    17                         // nextRandom() invocations. 
    18                         x = ++Ticket ; 
    19                         if (x == 0) x = 1 ; 
     12                        // Ticket is accessed infrequently and does not constitute a coherence hot-spot.
     13                        // Note that we use a non-atomic racy increment -- the race is rare and benign.
     14                        // If the race is a concern switch to an AtomicInteger.
     15                        // In addition accesses to the RW volatile global "Ticket"  variable are not
     16                        // (readily) predictable at compile-time so the JIT will not be able to elide
     17                        // nextRandom() invocations.
     18                        x = ++Ticket ;
     19                        if (x == 0) x = 1 ;
    2020                }
    2121                x ^= x << 6;
    2222                x ^= x >>> 21;
    2323                x ^= x << 7;
    24                 return x ;   
     24                return x ;
    2525        }
    2626        static int x = 2;
    2727
    28         static private int times = Integer.parseInt("100000000");
     28        static private long times = Long.parseLong("100000000");
    2929
    3030        public synchronized void noop() {
     
    3434                JavaThread j = new JavaThread();
    3535                // Inhibit biased locking ...
    36                 x = (j.hashCode() ^ System.identityHashCode(j)) | 1 ;     
    37                 for(int i = 1; i <= times; i += 1) {
     36                x = (j.hashCode() ^ System.identityHashCode(j)) | 1 ;
     37                for(long i = 1; i <= times; i += 1) {
    3838                        x = nextRandom(x);
    3939                        j.noop();
     
    4747        }
    4848        public static void main(String[] args) throws InterruptedException {
    49                 if ( args.length > 2 ) System.exit( 1 );
    50                 if ( args.length == 2 ) { times = Integer.parseInt(args[1]); }
     49                if ( args.length > 1 ) System.exit( 1 );
     50                if ( args.length == 1 ) { times = Long.parseLong(args[0]); }
    5151
    52                 for (int n = Integer.parseInt("5"); --n >= 0 ; ) { 
     52                for (int n = Integer.parseInt("5"); --n >= 0 ; ) {
    5353                        InnerMain();
    5454                        Thread.sleep(2000);     // 2 seconds
  • benchmark/mutexC/JavaThread.java

    r3c64c668 r58fe85a  
    11class Noop {
    22        // Simplistic low-quality Marsaglia Shift-XOR pseudo-random number generator.
    3         // Bijective   
     3        // Bijective
    44        // Cycle length for non-zero values is 4G-1.
    55        // 0 is absorbing and should be avoided -- fixed point.
    66        // The returned value is typically masked to produce a positive value.
    7         static volatile int Ticket = 0 ; 
     7        static volatile int Ticket = 0 ;
    88
    99        public static int nextRandom( int x ) {
    10                 if (x == 0) { 
     10                if (x == 0) {
    1111                        // reseed the PRNG
    12                         // Ticket is accessed infrequently and does not constitute a coherence hot-spot. 
    13                         // Note that we use a non-atomic racy increment -- the race is rare and benign. 
    14                         // If the race is a concern switch to an AtomicInteger. 
    15                         // In addition accesses to the RW volatile global "Ticket"  variable are not 
    16                         // (readily) predictable at compile-time so the JIT will not be able to elide 
    17                         // nextRandom() invocations. 
    18                         x = ++Ticket ; 
    19                         if (x == 0) x = 1 ; 
     12                        // Ticket is accessed infrequently and does not constitute a coherence hot-spot.
     13                        // Note that we use a non-atomic racy increment -- the race is rare and benign.
     14                        // If the race is a concern switch to an AtomicInteger.
     15                        // In addition accesses to the RW volatile global "Ticket"  variable are not
     16                        // (readily) predictable at compile-time so the JIT will not be able to elide
     17                        // nextRandom() invocations.
     18                        x = ++Ticket ;
     19                        if (x == 0) x = 1 ;
    2020                }
    2121                x ^= x << 6;
    2222                x ^= x >>> 21;
    2323                x ^= x << 7;
    24                 return x ;   
     24                return x ;
    2525        }
    2626}
     
    4747        static int x = 2;
    4848
    49         static private int times = Integer.parseInt("10000000");
     49        static private long times = Long.parseLong("10000000");
    5050
    5151        public static void call( Monitor m ) throws InterruptedException {
     
    5353                m.go = true;
    5454                //while ( ! m.go2 );
    55                 for ( int i = 0; i < times; i += 1 ) {
     55                for ( long i = 0; i < times; i += 1 ) {
    5656                        m.call();
    5757                        x = Noop.nextRandom( x );
     
    7171        public static void main( String[] args ) throws InterruptedException {
    7272                if ( args.length > 2 ) System.exit( 1 );
    73                 if ( args.length == 2 ) { times = Integer.parseInt(args[1]); }
     73                if ( args.length == 2 ) { times = Long.parseLong(args[1]); }
    7474
    75                 if ( args.length > 2 ) System.exit( 1 );
    76                 if ( args.length == 2 ) { times = Integer.parseInt(args[1]); }
    77 
    78                 for ( int i = Integer.parseInt("5"); --i >= 0 ; ) {
     75                for ( int i = Integer.parseInt("5"); --i >= 0 ; ) {
    7976                        InnerMain();
    8077                        // Thread.sleep(2000);  // 2 seconds
  • benchmark/schedint/JavaThread.java

    r3c64c668 r58fe85a  
    2424public class JavaThread {
    2525        // Simplistic low-quality Marsaglia Shift-XOR pseudo-random number generator.
    26         // Bijective   
     26        // Bijective
    2727        // Cycle length for non-zero values is 4G-1.
    2828        // 0 is absorbing and should be avoided -- fixed point.
    2929        // The returned value is typically masked to produce a positive value.
    30         static volatile int Ticket = 0 ; 
     30        static volatile int Ticket = 0 ;
    3131
    3232        private static int nextRandom (int x) {
    33                 if (x == 0) { 
     33                if (x == 0) {
    3434                        // reseed the PRNG
    35                         // Ticket is accessed infrequently and does not constitute a coherence hot-spot. 
    36                         // Note that we use a non-atomic racy increment -- the race is rare and benign. 
    37                         // If the race is a concern switch to an AtomicInteger. 
    38                         // In addition accesses to the RW volatile global "Ticket"  variable are not 
    39                         // (readily) predictable at compile-time so the JIT will not be able to elide 
    40                         // nextRandom() invocations. 
    41                         x = ++Ticket ; 
    42                         if (x == 0) x = 1 ; 
     35                        // Ticket is accessed infrequently and does not constitute a coherence hot-spot.
     36                        // Note that we use a non-atomic racy increment -- the race is rare and benign.
     37                        // If the race is a concern switch to an AtomicInteger.
     38                        // In addition accesses to the RW volatile global "Ticket"  variable are not
     39                        // (readily) predictable at compile-time so the JIT will not be able to elide
     40                        // nextRandom() invocations.
     41                        x = ++Ticket ;
     42                        if (x == 0) x = 1 ;
    4343                }
    4444                x ^= x << 6;
    4545                x ^= x >>> 21;
    4646                x ^= x << 7;
    47                 return x ;   
     47                return x ;
    4848        }
    4949        static int x = 2;
    5050
    51         static private int times = Integer.parseInt("1000000");
     51        static private long times = Long.parseLong("1000000");
    5252
    5353        public static void helper( Monitor m ) throws InterruptedException {
    54                 for(int i = 1; i <= times; i += 1) {
     54                for(long i = 1; i <= times; i += 1) {
    5555                        m.wait();               // relase monitor lock
    5656                        m.next = true;
     
    7575        }
    7676        public static void main(String[] args) throws InterruptedException {
    77                 if ( args.length > 2 ) System.exit( 1 );
    78                 if ( args.length == 2 ) { times = Integer.parseInt(args[1]); }
     77                if ( args.length > 1 ) System.exit( 1 );
     78                if ( args.length == 1 ) { times = Long.parseLong(args[0]); }
    7979
    80                 for (int n = Integer.parseInt("5"); --n >= 0 ; ) { 
     80                for (int n = Integer.parseInt("5"); --n >= 0 ; ) {
    8181                        InnerMain();
    8282                        Thread.sleep(2000);     // 2 seconds
Note: See TracChangeset for help on using the changeset viewer.