Added JIT warp-up phase
This commit is contained in:
parent
aa9e36d72c
commit
86c5fa2818
@ -25,6 +25,9 @@ public class Main {
|
|||||||
beforeStart();
|
beforeStart();
|
||||||
new DisplayManager(screen);
|
new DisplayManager(screen);
|
||||||
afterStart();
|
afterStart();
|
||||||
|
if (screen instanceof LoadingScreen) {
|
||||||
|
((LoadingScreen) screen).loaded = true;
|
||||||
|
}
|
||||||
DisplayManager.INSTANCE.waitForExit();
|
DisplayManager.INSTANCE.waitForExit();
|
||||||
Utils.out.println(1, "Shutdown...");
|
Utils.out.println(1, "Shutdown...");
|
||||||
beforeShutdown();
|
beforeShutdown();
|
||||||
@ -82,6 +85,7 @@ public class Main {
|
|||||||
public void afterStart() {
|
public void afterStart() {
|
||||||
DisplayManager.INSTANCE.setBrightness(0.2f);
|
DisplayManager.INSTANCE.setBrightness(0.2f);
|
||||||
RulesManager.initialize();
|
RulesManager.initialize();
|
||||||
|
RulesManager.warmUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void beforeShutdown() {
|
public void beforeShutdown() {
|
||||||
|
@ -10,6 +10,7 @@ public class LoadingScreen extends Screen {
|
|||||||
public float endLoading;
|
public float endLoading;
|
||||||
boolean mustRefresh = true;
|
boolean mustRefresh = true;
|
||||||
public float loadingTextTranslation = 0.0f;
|
public float loadingTextTranslation = 0.0f;
|
||||||
|
public boolean loaded = false;
|
||||||
|
|
||||||
public LoadingScreen() {
|
public LoadingScreen() {
|
||||||
super();
|
super();
|
||||||
@ -29,7 +30,7 @@ public class LoadingScreen extends Screen {
|
|||||||
loadingTextTranslation = GraphicUtils.sinDeg(endLoading * 90f) * 10f;
|
loadingTextTranslation = GraphicUtils.sinDeg(endLoading * 90f) * 10f;
|
||||||
|
|
||||||
endLoading += dt;
|
endLoading += dt;
|
||||||
if (StaticVars.debugOn || endLoading >= 5f) {
|
if (loaded && (StaticVars.debugOn || endLoading >= 3.5f)) {
|
||||||
DisplayManager.INSTANCE.setScreen(new MathInputScreen());
|
DisplayManager.INSTANCE.setScreen(new MathInputScreen());
|
||||||
}
|
}
|
||||||
mustRefresh = true;
|
mustRefresh = true;
|
||||||
|
@ -24,9 +24,13 @@ import javax.script.ScriptEngine;
|
|||||||
import javax.script.ScriptEngineManager;
|
import javax.script.ScriptEngineManager;
|
||||||
import javax.script.ScriptException;
|
import javax.script.ScriptException;
|
||||||
|
|
||||||
|
import org.warp.picalculator.Error;
|
||||||
import org.warp.picalculator.StaticVars;
|
import org.warp.picalculator.StaticVars;
|
||||||
import org.warp.picalculator.Utils;
|
import org.warp.picalculator.Utils;
|
||||||
|
import org.warp.picalculator.math.Function;
|
||||||
import org.warp.picalculator.math.MathContext;
|
import org.warp.picalculator.math.MathContext;
|
||||||
|
import org.warp.picalculator.math.MathSolver;
|
||||||
|
import org.warp.picalculator.math.functions.Expression;
|
||||||
import org.warp.picalculator.math.functions.Subtraction;
|
import org.warp.picalculator.math.functions.Subtraction;
|
||||||
import org.warp.picalculator.math.functions.Sum;
|
import org.warp.picalculator.math.functions.Sum;
|
||||||
import org.warp.picalculator.math.functions.SumSubtraction;
|
import org.warp.picalculator.math.functions.SumSubtraction;
|
||||||
@ -73,6 +77,31 @@ public class RulesManager {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void warmUp() {
|
||||||
|
ObjectArrayList<Function> uselessResult = null;
|
||||||
|
boolean uselessVariable;
|
||||||
|
for (RuleType val : RuleType.values()) {
|
||||||
|
final ObjectArrayList<Rule> ruleList = rules[val.ordinal()];
|
||||||
|
for (final Rule rule : ruleList) {
|
||||||
|
ObjectArrayList<Function> uselessResult2 = rule.execute(generateUselessExpression());
|
||||||
|
uselessVariable = (uselessResult == null ? new ObjectArrayList<>() : uselessResult).equals(uselessResult2);
|
||||||
|
uselessResult = uselessResult2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
new MathSolver(generateUselessExpression()).solveAllSteps();
|
||||||
|
} catch (InterruptedException | Error e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Expression generateUselessExpression() {
|
||||||
|
MathContext mc = new MathContext();
|
||||||
|
Expression expr = new Expression(mc);
|
||||||
|
expr = (Expression) expr.setParameter(new Variable(mc, 'x', V_TYPE.VARIABLE));
|
||||||
|
return expr;
|
||||||
|
}
|
||||||
|
|
||||||
public static void addRule(Rule rule) {
|
public static void addRule(Rule rule) {
|
||||||
rules[rule.getRuleType().ordinal()].add(rule);
|
rules[rule.getRuleType().ordinal()].add(rule);
|
||||||
|
Loading…
Reference in New Issue
Block a user