Changeset 58fe85a for benchmark/creation
- Timestamp:
- Jan 7, 2021, 3:27:00 PM (5 years ago)
- 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. - Location:
- benchmark/creation
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
benchmark/creation/JavaThread.java
r3c64c668 r58fe85a 1 1 public class JavaThread { 2 2 // Simplistic low-quality Marsaglia Shift-XOR pseudo-random number generator. 3 // Bijective 3 // Bijective 4 4 // Cycle length for non-zero values is 4G-1. 5 5 // 0 is absorbing and should be avoided -- fixed point. 6 6 // The returned value is typically masked to produce a positive value. 7 static volatile int Ticket = 0 ; 7 static volatile int Ticket = 0 ; 8 8 9 9 private static int nextRandom (int x) { 10 if (x == 0) { 10 if (x == 0) { 11 11 // 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 ; 20 20 } 21 21 x ^= x << 6; 22 22 x ^= x >>> 21; 23 23 x ^= x << 7; 24 return x ; 24 return x ; 25 25 } 26 26 static int x = 2; 27 27 28 static private int times = Integer.parseInt("10000") ;28 static private long times = Long.parseLong("10000") ; 29 29 30 30 public static class MyThread extends Thread { … … 33 33 } 34 34 public static void helper() throws InterruptedException { 35 for( inti = 1; i <= times; i += 1) {35 for(long i = 1; i <= times; i += 1) { 36 36 MyThread m = new MyThread(); 37 37 x = nextRandom( x ); … … 47 47 } 48 48 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]); } 51 51 52 for (int i = Integer.parseInt("5"); --i >= 0 ; ) { 52 for (int i = Integer.parseInt("5"); --i >= 0 ; ) { 53 53 InnerMain(); 54 54 Thread.sleep(2000); // 2 seconds -
benchmark/creation/cfa_gen.cfa
r3c64c668 r58fe85a 1 #include " bench.h"1 #include "../bench.h" 2 2 3 struct C{3 generator G { 4 4 volatile int restart; // ensure compiler does not optimize away all the code 5 5 }; 6 void ?{}( C & c ) { c.restart = 0; }7 void main( C& ) {}6 void ?{}( G & g ) { g.restart = 0; } 7 void main( G & ) {} 8 8 9 9 int main( int argc, char * argv[] ) { … … 11 11 BENCH( 12 12 for ( times ) { 13 C c;13 G g; 14 14 }, 15 15 result
Note:
See TracChangeset
for help on using the changeset viewer.