-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReproducerScriptThread.java
More file actions
49 lines (41 loc) · 1.81 KB
/
ReproducerScriptThread.java
File metadata and controls
49 lines (41 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import jdk.nashorn.api.scripting.NashornScriptEngine;
import jdk.nashorn.api.scripting.NashornScriptEngineFactory;
import javax.script.ScriptException;
import java.io.IOException;
public class ReproducerScriptThread {
private static int THREAD_COUNT = 500;
private static int SCRIPT_LOOP_COUNT = 500;
public static void main(String[] args) throws IOException, ScriptException, InterruptedException {
new ReproducerScriptThread().reproduce();
}
private void reproduce() throws IOException, ScriptException, InterruptedException {
System.out.println("Starting reproducer in 5 seconds, run NMT baseline now");
Thread.sleep(5000);
NashornScriptEngineFactory factory = new NashornScriptEngineFactory();
NashornScriptEngine engine = getEngine(factory);
for (int i = 0; i < THREAD_COUNT; i++) {
System.out.println("Thread " + i + " starting");
ScriptThread thread = new ScriptThread(engine, SCRIPT_LOOP_COUNT);
thread.start();
thread.join();
System.out.println("Thread " + (i + 1) + " complete, doing GC");
System.gc();
}
System.out.println("All done with threads!");
System.out.println("Making engine go away");
engine = null;
Thread.sleep(1000);
System.gc();
Thread.sleep(1000);
System.gc();
Thread.sleep(1000);
System.gc();
System.out.println("Program will end in 5 seconds, run NMT summary.diff");
Thread.sleep(5000);
System.out.println("END!");
}
private NashornScriptEngine getEngine(NashornScriptEngineFactory factory) {
return (NashornScriptEngine) factory.getScriptEngine(new String[]{"--no-java", "-strict",
"--no-syntax-extensions", "--language=es6"});
}
}