profile expression

This commit is contained in:
gnembon committed 2019-07-22 03:37:14 -03:00
1 parent 1083740f17
commit cae7efdf4b
2 files changed
+15 -1

No files matched your search

@@ -2527,6 +2527,20 @@ public class Expression implements Cloneable
return (cc, tt) -> time;
});
addLazyFunction("profile_expr", 1, (c, t, lv) ->
{
LazyValue lazy = lv.get(0);
long end = System.nanoTime()+50000000L;
long it = 0;
while (System.nanoTime()<end)
{
lazy.evalValue(c);
it++;
}
Value res = new NumericValue(it);
return (cc, tt) -> res;
});
addLazyFunction("var", 1, (c, t, lv) -> {
String varname = lv.get(0).evalValue(c).getString();
if (!c.isAVariable(varname))
@@ -208,7 +208,7 @@ public class BlockValue extends Value
data = be.toTag(tag);
return data;
}
throw new InternalExpressionException("Attemted to fetch block data without world or stored block data");
return null;
}