Only export statistics(runtime,_) for STATISTICS_RUNTIME
This avoids the need to access the system clock during initialization
of an interpreter, and prevents code from getting the difference
in wall clock time during execution.
diff --git a/src/builtin/PRED_$statistics_2.java b/src/builtin/PRED_$statistics_2.java
index a0753ac..ab1778f 100644
--- a/src/builtin/PRED_$statistics_2.java
+++ b/src/builtin/PRED_$statistics_2.java
@@ -31,6 +31,7 @@
} else if (! a1.isSymbol()) {
throw new IllegalTypeException(this, 1, "atom", a1);
} else if (a1.equals(SYM_RUNTIME)) {
+ engine.requireFeature(Prolog.Feature.STATISTICS_RUNTIME, this, a1);
long val1, val2;
Term start, previous;
val1 = System.currentTimeMillis() - engine.getStartRuntime();
diff --git a/src/lang/Prolog.java b/src/lang/Prolog.java
index 222e37a..1e5d7a2 100644
--- a/src/lang/Prolog.java
+++ b/src/lang/Prolog.java
@@ -156,7 +156,10 @@
JAVA_REFLECTION,
/** Access to the local filesystem and console. */
- IO;
+ IO,
+
+ /** Track the running time of evaluations */
+ STATISTICS_RUNTIME;
}
protected final EnumSet<Feature> features = EnumSet.allOf(Feature.class);
@@ -251,8 +254,10 @@
doubleQuotes = "codes";
printStackTrace = "off";
- exception = NONE;
- startRuntime = System.currentTimeMillis();
+ exception = NONE;
+ startRuntime = features.contains(Feature.STATISTICS_RUNTIME)
+ ? System.currentTimeMillis()
+ : 0;
previousRuntime = 0;
userOutput.flush();