comparison truffle/com.oracle.truffle.api.interop.java.test/src/com/oracle/truffle/api/interop/java/test/JavaInteropSpeedTest.java @ 22241:14e6dfb1ef05

Truffle/Testing: massive rework of tests to accommodate recent instrumentation change with respect to "applyInstrumentation" - Caused by lack of a "vm" known to the Accessor during most testing, making the Instrumenter unavailable, which is now required to create a CallTarget - Modified the Instrumenter/Accessor with a static field that can be reflectively "poked" with a vm value for testing - Create a pair of methods to globally enable/disable testing mode to modify that static field and restore it when tests complete.
author Michael Van De Vanter <michael.van.de.vanter@oracle.com>
date Tue, 22 Sep 2015 20:31:19 -0700
parents dc83cc1f94f2
children 0d36601f233e
comparison
equal deleted inserted replaced
22240:f78c72e2e0b6 22241:14e6dfb1ef05
22 * or visit www.oracle.com if you need additional information or have any 22 * or visit www.oracle.com if you need additional information or have any
23 * questions. 23 * questions.
24 */ 24 */
25 package com.oracle.truffle.api.interop.java.test; 25 package com.oracle.truffle.api.interop.java.test;
26 26
27 import static org.junit.Assert.assertEquals;
28 import static org.junit.Assert.fail;
29
30 import java.util.Random;
31
32 import org.junit.AfterClass;
33 import org.junit.BeforeClass;
34 import org.junit.Test;
35
27 import com.oracle.truffle.api.interop.TruffleObject; 36 import com.oracle.truffle.api.interop.TruffleObject;
28 import com.oracle.truffle.api.interop.java.JavaInterop; 37 import com.oracle.truffle.api.interop.java.JavaInterop;
29 import java.util.Random;
30 import org.junit.AfterClass;
31 import static org.junit.Assert.assertEquals;
32 import static org.junit.Assert.fail;
33 import org.junit.BeforeClass;
34 import org.junit.Test;
35 38
36 public class JavaInteropSpeedTest { 39 public class JavaInteropSpeedTest {
37 private static final int REPEAT = 10000; 40 private static final int REPEAT = 10000;
38 private static int[] arr; 41 private static int[] arr;
39 private static long javaTime; 42 private static long javaTime;
40 private static long interopTime; 43 private static long interopTime;
41 44
42 @BeforeClass 45 @BeforeClass
43 public static void beforeTesting() { 46 public static void beforeTesting() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
47 InstrumentationTestMode.set(true);
44 arr = initArray(REPEAT); 48 arr = initArray(REPEAT);
45 for (int i = 0; i < 1000; i++) { 49 for (int i = 0; i < 1000; i++) {
46 JavaInteropSpeedTest t = new JavaInteropSpeedTest(); 50 JavaInteropSpeedTest t = new JavaInteropSpeedTest();
47 t.doMinMaxInJava(); 51 t.doMinMaxInJava();
48 t.doMinMaxWithInterOp(); 52 t.doMinMaxWithInterOp();
49 t.assertSame(); 53 t.assertSame();
50 } 54 }
55 }
56
57 @AfterClass
58 public static void after() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
59 InstrumentationTestMode.set(false);
51 } 60 }
52 61
53 private int mmInOp; 62 private int mmInOp;
54 private int mmInJava; 63 private int mmInJava;
55 64