Le support aux utilisateurs et les demandes de création de comptes externes doivent être faites depuis les issues du projet GitLab HEFR (https://gitlab.forge.hefr.ch/forge-hefr/gitlab-hefr)

Commit 3c7df11c authored by Tony Licata's avatar Tony Licata
Browse files

cleaned code, prepared code in ProofTreeNode to optimize it

parent e7a24adb
package ch.heiafr.prolograal.builtins.predicates;
import ch.heiafr.prolograal.runtime.*;
import com.oracle.truffle.api.CompilerDirectives;
import java.io.PrintWriter;
import java.util.*;
import java.util.function.Function;
......@@ -18,17 +20,15 @@ public final class ProloGraalIsBuiltin extends ProloGraalBuiltinClause {
private ProloGraalVariable arg; // the variable A in is(A,B). We keep it to use it in the execute method
private ProloGraalVariable arg2; // the variable B in is(A,B). We keep it to use it in the execute method
private final Map<ProloGraalAtom, Function<List<ProloGraalNumber>,ProloGraalNumber>> operations;
// we fill the operations map to check the operator used by the user later in the execute method
private static final Map<ProloGraalAtom, Function<List<ProloGraalNumber>,ProloGraalNumber>> operations = fillOperations();
public ProloGraalIsBuiltin(ProloGraalContext context) {
super();
this.writer = new PrintWriter(context.getOutput(), true);
this.context = context;
// we fill the operations map to check the operator used by the user later in the execute method
operations = new HashMap<>();
fillOperations(operations);
// create the head of this clause
// since we do not need custom unification, a simple structure is enough
ProloGraalStructure head = new ProloGraalStructure(getVariables());
......@@ -51,7 +51,7 @@ public final class ProloGraalIsBuiltin extends ProloGraalBuiltinClause {
public ProloGraalBoolean execute() {
ProloGraalTerm leftTerm = arg.getRootValue();
ProloGraalTerm rightTerm = arg2.getRootValue();
if(leftTerm instanceof ProloGraalVariable || leftTerm instanceof ProloGraalNumber){
if(leftTerm.isVariable() || leftTerm.isNumber()){
ProloGraalNumber result = consultTerm(rightTerm);
if(result==null){
writer.print("op nok");
......@@ -109,178 +109,179 @@ public final class ProloGraalIsBuiltin extends ProloGraalBuiltinClause {
}
/* is/2 operators */
private ProloGraalNumber pi(List<ProloGraalNumber> args){
if(!args.isEmpty())return null;
return new ProloGraalDoubleNumber(getVariables(),Math.PI);
private static ProloGraalNumber pi(List<ProloGraalNumber> args) {
if (!args.isEmpty()) return null;
return new ProloGraalDoubleNumber(new HashMap<>(), Math.PI);
}
private ProloGraalNumber e(List<ProloGraalNumber> args){
if(!args.isEmpty())return null;
return new ProloGraalDoubleNumber(getVariables(),Math.E);
private static ProloGraalNumber e(List<ProloGraalNumber> args) {
if (!args.isEmpty()) return null;
return new ProloGraalDoubleNumber(new HashMap<>(), Math.E);
}
private ProloGraalNumber tau(List<ProloGraalNumber> args){
if(!args.isEmpty())return null;
return new ProloGraalDoubleNumber(getVariables(),Math.PI*2);
private static ProloGraalNumber tau(List<ProloGraalNumber> args) {
if (!args.isEmpty()) return null;
return new ProloGraalDoubleNumber(new HashMap<>(), Math.PI * 2);
}
private ProloGraalNumber add(List<ProloGraalNumber> args){
if(args.size()!=2)return null;
private static ProloGraalNumber add(List<ProloGraalNumber> args) {
if (args.size() != 2) return null;
ProloGraalNumber arg0 = args.get(0), arg1 = args.get(1);
if(areAllIntegers(arg0,arg1))
return new ProloGraalIntegerNumber(getVariables(),arg0.asInteger()+arg1.asInteger());
return new ProloGraalDoubleNumber(getVariables(),arg0.asDouble()+arg1.asDouble());
if (areAllIntegers(arg0, arg1))
return new ProloGraalIntegerNumber(new HashMap<>(), arg0.asInteger() + arg1.asInteger());
return new ProloGraalDoubleNumber(new HashMap<>(), arg0.asDouble() + arg1.asDouble());
}
private ProloGraalNumber substract(List<ProloGraalNumber> args){
if(args.size()!=2)return null;
private static ProloGraalNumber substract(List<ProloGraalNumber> args) {
if (args.size() != 2) return null;
ProloGraalNumber arg0 = args.get(0), arg1 = args.get(1);
if(areAllIntegers(arg0,arg1))
return new ProloGraalIntegerNumber(getVariables(),arg0.asInteger()-arg1.asInteger());
return new ProloGraalDoubleNumber(getVariables(),arg0.asDouble()-arg1.asDouble());
if (areAllIntegers(arg0, arg1))
return new ProloGraalIntegerNumber(new HashMap<>(), arg0.asInteger() - arg1.asInteger());
return new ProloGraalDoubleNumber(new HashMap<>(), arg0.asDouble() - arg1.asDouble());
}
private ProloGraalNumber multiply(List<ProloGraalNumber> args){
if(args.size()!=2)return null;
private static ProloGraalNumber multiply(List<ProloGraalNumber> args) {
if (args.size() != 2) return null;
ProloGraalNumber arg0 = args.get(0), arg1 = args.get(1);
if(areAllIntegers(arg0,arg1))
return new ProloGraalIntegerNumber(getVariables(),arg0.asInteger()*arg1.asInteger());
return new ProloGraalDoubleNumber(getVariables(),arg0.asDouble()*arg1.asDouble());
if (areAllIntegers(arg0, arg1))
return new ProloGraalIntegerNumber(new HashMap<>(), arg0.asInteger() * arg1.asInteger());
return new ProloGraalDoubleNumber(new HashMap<>(), arg0.asDouble() * arg1.asDouble());
}
private ProloGraalNumber divide(List<ProloGraalNumber> args){
if(args.size()!=2)return null;
return new ProloGraalDoubleNumber(getVariables(),args.get(0).asDouble()/args.get(1).asDouble());
private static ProloGraalNumber divide(List<ProloGraalNumber> args) {
if (args.size() != 2) return null;
return new ProloGraalDoubleNumber(new HashMap<>(), args.get(0).asDouble() / args.get(1).asDouble());
}
private ProloGraalNumber pow(List<ProloGraalNumber> args){
if(args.size()!=2)return null;
private static ProloGraalNumber pow(List<ProloGraalNumber> args) {
if (args.size() != 2) return null;
ProloGraalNumber arg0 = args.get(0), arg1 = args.get(1);
if(areAllIntegers(arg0,arg1) && Math.abs(Math.pow(arg0.asInteger(),arg1.asInteger()))<Integer.MAX_VALUE)
return new ProloGraalIntegerNumber(getVariables(),(int)Math.pow(arg0.asInteger(),arg1.asInteger()));
return new ProloGraalDoubleNumber(getVariables(),Math.pow(arg0.asDouble(),arg1.asDouble()));
if (areAllIntegers(arg0, arg1) && Math.abs(Math.pow(arg0.asInteger(), arg1.asInteger())) < Integer.MAX_VALUE)
return new ProloGraalIntegerNumber(new HashMap<>(), (int) Math.pow(arg0.asInteger(), arg1.asInteger()));
return new ProloGraalDoubleNumber(new HashMap<>(), Math.pow(arg0.asDouble(), arg1.asDouble()));
}
private ProloGraalNumber sqrt(List<ProloGraalNumber> args){
if(args.size()!=1)return null;
return new ProloGraalDoubleNumber(getVariables(),Math.sqrt(args.get(0).asDouble()));
private static ProloGraalNumber sqrt(List<ProloGraalNumber> args) {
if (args.size() != 1) return null;
return new ProloGraalDoubleNumber(new HashMap<>(), Math.sqrt(args.get(0).asDouble()));
}
private ProloGraalNumber rem(List<ProloGraalNumber> args){
if(args.size()!=2)return null;
private static ProloGraalNumber rem(List<ProloGraalNumber> args) {
if (args.size() != 2) return null;
ProloGraalNumber arg0 = args.get(0), arg1 = args.get(1);
if(areAllIntegers(arg0,arg1))
return new ProloGraalIntegerNumber(getVariables(),arg0.asInteger()%arg1.asInteger());
return new ProloGraalDoubleNumber(getVariables(),arg0.asDouble()%arg1.asDouble());
if (areAllIntegers(arg0, arg1))
return new ProloGraalIntegerNumber(new HashMap<>(), arg0.asInteger() % arg1.asInteger());
return new ProloGraalDoubleNumber(new HashMap<>(), arg0.asDouble() % arg1.asDouble());
}
private ProloGraalNumber mod(List<ProloGraalNumber> args){
if(args.size()!=2)return null;
private static ProloGraalNumber mod(List<ProloGraalNumber> args) {
if (args.size() != 2) return null;
ProloGraalNumber arg0 = args.get(0), arg1 = args.get(1);
double ad = arg0.asDouble();
double bd = arg1.asDouble();
double res = ((ad % bd + bd) % bd);
if(areAllIntegers(arg0,arg1))
return new ProloGraalIntegerNumber(getVariables(),(int)res);
return new ProloGraalDoubleNumber(getVariables(),res);
if (areAllIntegers(arg0, arg1))
return new ProloGraalIntegerNumber(new HashMap<>(), (int) res);
return new ProloGraalDoubleNumber(new HashMap<>(), res);
}
private ProloGraalNumber sign(List<ProloGraalNumber> args){
if(args.size()!=1)return null;
private static ProloGraalNumber sign(List<ProloGraalNumber> args) {
if (args.size() != 1) return null;
double val = args.get(0).asDouble();
int res = 0;
if(val>0) res = 1;
if(val<0) res = -1;
return new ProloGraalIntegerNumber(getVariables(),res);
if (val > 0) res = 1;
if (val < 0) res = -1;
return new ProloGraalIntegerNumber(new HashMap<>(), res);
}
private ProloGraalNumber exp(List<ProloGraalNumber> args){
if(args.size()!=1)return null;
return new ProloGraalDoubleNumber(getVariables(),Math.exp(args.get(0).asDouble()));
private static ProloGraalNumber exp(List<ProloGraalNumber> args) {
if (args.size() != 1) return null;
return new ProloGraalDoubleNumber(new HashMap<>(), Math.exp(args.get(0).asDouble()));
}
private ProloGraalNumber log(List<ProloGraalNumber> args){
if(args.size()!=1)return null;
return new ProloGraalDoubleNumber(getVariables(),Math.log(args.get(0).asDouble()));
private static ProloGraalNumber log(List<ProloGraalNumber> args) {
if (args.size() != 1) return null;
return new ProloGraalDoubleNumber(new HashMap<>(), Math.log(args.get(0).asDouble()));
}
private ProloGraalNumber sin(List<ProloGraalNumber> args){
if(args.size()!=1)return null;
return new ProloGraalDoubleNumber(getVariables(),Math.sin(args.get(0).asDouble()));
private static ProloGraalNumber sin(List<ProloGraalNumber> args) {
if (args.size() != 1) return null;
return new ProloGraalDoubleNumber(new HashMap<>(), Math.sin(args.get(0).asDouble()));
}
private ProloGraalNumber cos(List<ProloGraalNumber> args){
if(args.size()!=1)return null;
return new ProloGraalDoubleNumber(getVariables(),Math.cos(args.get(0).asDouble()));
private static ProloGraalNumber cos(List<ProloGraalNumber> args) {
if (args.size() != 1) return null;
return new ProloGraalDoubleNumber(new HashMap<>(), Math.cos(args.get(0).asDouble()));
}
private ProloGraalNumber tan(List<ProloGraalNumber> args){
if(args.size()!=1)return null;
return new ProloGraalDoubleNumber(getVariables(),Math.tan(args.get(0).asDouble()));
private static ProloGraalNumber tan(List<ProloGraalNumber> args) {
if (args.size() != 1) return null;
return new ProloGraalDoubleNumber(new HashMap<>(), Math.tan(args.get(0).asDouble()));
}
private ProloGraalNumber asin(List<ProloGraalNumber> args){
if(args.size()!=1)return null;
return new ProloGraalDoubleNumber(getVariables(),Math.asin(args.get(0).asDouble()));
private static ProloGraalNumber asin(List<ProloGraalNumber> args) {
if (args.size() != 1) return null;
return new ProloGraalDoubleNumber(new HashMap<>(), Math.asin(args.get(0).asDouble()));
}
private ProloGraalNumber acos(List<ProloGraalNumber> args){
if(args.size()!=1)return null;
return new ProloGraalDoubleNumber(getVariables(),Math.acos(args.get(0).asDouble()));
private static ProloGraalNumber acos(List<ProloGraalNumber> args) {
if (args.size() != 1) return null;
return new ProloGraalDoubleNumber(new HashMap<>(), Math.acos(args.get(0).asDouble()));
}
private ProloGraalNumber atan(List<ProloGraalNumber> args){
if(args.size()!=1)return null;
return new ProloGraalDoubleNumber(getVariables(),Math.atan(args.get(0).asDouble()));
private static ProloGraalNumber atan(List<ProloGraalNumber> args) {
if (args.size() != 1) return null;
return new ProloGraalDoubleNumber(new HashMap<>(), Math.atan(args.get(0).asDouble()));
}
private ProloGraalNumber atan2(List<ProloGraalNumber> args){
if(args.size()!=2)return null;
return new ProloGraalDoubleNumber(getVariables(),Math.atan2(args.get(0).asDouble(),args.get(1).asDouble()));
private static ProloGraalNumber atan2(List<ProloGraalNumber> args) {
if (args.size() != 2) return null;
return new ProloGraalDoubleNumber(new HashMap<>(), Math.atan2(args.get(0).asDouble(), args.get(1).asDouble()));
}
private ProloGraalNumber abs(List<ProloGraalNumber> args){
if(args.size()!=1)return null;
private static ProloGraalNumber abs(List<ProloGraalNumber> args) {
if (args.size() != 1) return null;
ProloGraalNumber arg0 = args.get(0);
if(areAllIntegers(arg0))
return new ProloGraalIntegerNumber(getVariables(),Math.abs(arg0.asInteger()));
return new ProloGraalDoubleNumber(getVariables(),Math.abs(arg0.asDouble()));
if (areAllIntegers(arg0))
return new ProloGraalIntegerNumber(new HashMap<>(), Math.abs(arg0.asInteger()));
return new ProloGraalDoubleNumber(new HashMap<>(), Math.abs(arg0.asDouble()));
}
private void fillOperations(Map<ProloGraalAtom, Function<List<ProloGraalNumber>,ProloGraalNumber>> operations){
addOpperation(operations,"pi",this::pi);
addOpperation(operations,"e",this::e);
addOpperation(operations,"tau",this::tau);
addOpperation(operations,"+",this::add);
addOpperation(operations,"-",this::substract);
addOpperation(operations,"*",this::multiply);
addOpperation(operations,"/",this::divide);
addOpperation(operations,"**",this::pow);
addOpperation(operations,"^",this::pow);
addOpperation(operations,"sqrt",this::sqrt);
addOpperation(operations,"rem",this::rem);
addOpperation(operations,"mod",this::mod);
addOpperation(operations,"sign",this::sign);
addOpperation(operations,"exp",this::exp);
addOpperation(operations,"log",this::log);
addOpperation(operations,"sin",this::sin);
addOpperation(operations,"cos",this::cos);
addOpperation(operations,"tan",this::tan);
addOpperation(operations,"asin",this::asin);
addOpperation(operations,"acos",this::acos);
addOpperation(operations,"atan",this::atan);
addOpperation(operations,"atan2",this::atan2);
addOpperation(operations,"abs",this::abs);
private static Map<ProloGraalAtom, Function<List<ProloGraalNumber>,ProloGraalNumber>> fillOperations(){
Map<ProloGraalAtom, Function<List<ProloGraalNumber>,ProloGraalNumber>> operationsMap = new HashMap<>();
addOpperation(operationsMap,"pi",ProloGraalIsBuiltin::pi);
addOpperation(operationsMap,"e",ProloGraalIsBuiltin::e);
addOpperation(operationsMap,"tau",ProloGraalIsBuiltin::tau);
addOpperation(operationsMap,"+",ProloGraalIsBuiltin::add);
addOpperation(operationsMap,"-",ProloGraalIsBuiltin::substract);
addOpperation(operationsMap,"*",ProloGraalIsBuiltin::multiply);
addOpperation(operationsMap,"/",ProloGraalIsBuiltin::divide);
addOpperation(operationsMap,"**",ProloGraalIsBuiltin::pow);
addOpperation(operationsMap,"^",ProloGraalIsBuiltin::pow);
addOpperation(operationsMap,"sqrt",ProloGraalIsBuiltin::sqrt);
addOpperation(operationsMap,"rem",ProloGraalIsBuiltin::rem);
addOpperation(operationsMap,"mod",ProloGraalIsBuiltin::mod);
addOpperation(operationsMap,"sign",ProloGraalIsBuiltin::sign);
addOpperation(operationsMap,"exp",ProloGraalIsBuiltin::exp);
addOpperation(operationsMap,"log",ProloGraalIsBuiltin::log);
addOpperation(operationsMap,"sin",ProloGraalIsBuiltin::sin);
addOpperation(operationsMap,"cos",ProloGraalIsBuiltin::cos);
addOpperation(operationsMap,"tan",ProloGraalIsBuiltin::tan);
addOpperation(operationsMap,"asin",ProloGraalIsBuiltin::asin);
addOpperation(operationsMap,"acos",ProloGraalIsBuiltin::acos);
addOpperation(operationsMap,"atan",ProloGraalIsBuiltin::atan);
addOpperation(operationsMap,"atan2",ProloGraalIsBuiltin::atan2);
addOpperation(operationsMap,"abs",ProloGraalIsBuiltin::abs);
return operationsMap;
}
private void addOpperation(Map<ProloGraalAtom, Function<List<ProloGraalNumber>,ProloGraalNumber>> operations,
private static void addOpperation(Map<ProloGraalAtom, Function<List<ProloGraalNumber>,ProloGraalNumber>> operations,
String atomName,
Function<List<ProloGraalNumber>,ProloGraalNumber> function){
operations.put(new ProloGraalAtom(getVariables(),atomName), function);
operations.put(new ProloGraalAtom(new HashMap<>(),atomName), function);
}
private boolean areAllIntegers(ProloGraalNumber<?>... args){
private static boolean areAllIntegers(ProloGraalNumber<?>... args){
for (ProloGraalNumber number : args)
if(!number.isInteger())return false;
return true;
......
......@@ -2,6 +2,7 @@ package ch.heiafr.prolograal.builtins.predicates;
import ch.heiafr.prolograal.runtime.*;
import java.util.Date;
import java.util.Map;
/**
......@@ -10,55 +11,37 @@ import java.util.Map;
* @author Martin Spoto
* @see ProloGraalBuiltinClause
*/
public final class ProloGraalVarBuiltin extends ProloGraalBuiltinClause {
public final class ProloGraalRealTimeBuiltin extends ProloGraalBuiltinClause {
/**
* Class representing the head of this predicate.
* Necessary to override the unification behaviour.
*/
private static class VarPredicateHead extends ProloGraalStructure {
private static final long startTime = System.currentTimeMillis();
private ProloGraalVariable arg; // the variable A in real_time(A). We keep it to use it in the execute method
public VarPredicateHead(Map<ProloGraalVariable, ProloGraalVariable> variables) {
super(variables);
// add the correct functor for this predicate, and an anonymous variable since we do not need it
setFunctor(new ProloGraalAtom(variables, "var"));
addSubterm(new ProloGraalVariable(variables, "_"));
}
public ProloGraalRealTimeBuiltin() {
super();
/**
* Overrides the default structure unification behaviour.
* Checks that the param has the same functor and exactly one argument, then checks that the argument
* resolves to a variable
* @return true if other has the same functor and exactly one argument, and that argument is an unbound variable
*/
@Override
public boolean unify(ProloGraalTerm<?> other) {
if (other instanceof ProloGraalStructure) {
ProloGraalStructure struct = (ProloGraalStructure) other;
if (struct.getFunctor().equals(getFunctor()) && struct.getArity() == 1) {
return struct.getArguments().get(0).getRootValue() instanceof ProloGraalVariable;
}
}
return false;
}
// create the head of this clause
// since we do not need custom unification, a simple structure is enough
ProloGraalStructure head = new ProloGraalStructure(getVariables());
head.setFunctor(new ProloGraalAtom(getVariables(), "real_time"));
// override the default copy so we do not lose the custom unification behaviour
@Override
public ProloGraalStructure copy(Map<ProloGraalVariable, ProloGraalVariable> variables) {
return new VarPredicateHead(variables);
}
}
// we create and store the variables to access them more easily later in the execute method
arg = new ProloGraalVariable(getVariables(), "A");
head.addSubterm(arg);
public ProloGraalVarBuiltin() {
super();
// creates our custom head and set it
VarPredicateHead head = new VarPredicateHead(getVariables());
setHead(head);
}
@Override
public ProloGraalBoolean execute(){
if(arg.isNumber() || arg.isBound() && arg.getRootValue().isVariable())
if(arg.unify(new ProloGraalDoubleNumber(getVariables(),System.currentTimeMillis()-startTime)))
return new ProloGraalSuccess(getVariables());
return new ProloGraalFailure();
}
// override the default copy so we do not lose the custom head
@Override
public ProloGraalClause copy() {
return new ProloGraalVarBuiltin();
return new ProloGraalRealTimeBuiltin();
}
}
......@@ -6,6 +6,7 @@ import ch.heiafr.prolograal.runtime.*;
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
import com.oracle.truffle.api.Truffle;
import com.oracle.truffle.api.TruffleLanguage;
import com.oracle.truffle.api.TruffleLanguage.ContextReference;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.RootNode;
......@@ -70,14 +71,6 @@ public final class ProloGraalEvalRootNode extends RootNode {
Deque<Integer> currentBranches = new ArrayDeque<>();
ProloGraalClause goal = new ProloGraalClause();
goal.setHead(new ProloGraalAtom(request.getVariables(),"goals"));
/*
if(request.getGoals().size()==0){
goal.addGoal(request.getHead());
}else if(request.getGoals().size()>0 && request.getHead() == null){
request.getGoals().forEach(proloGraalTerm -> goal.addGoal(proloGraalTerm));
} else{
continue;
} */
request.getGoals().forEach(proloGraalTerm -> goal.addGoal(proloGraalTerm));
ProloGraalRuntime runtime;
runtime = new ProloGraalRuntime(language.getContextReference().get());
......
......@@ -31,7 +31,6 @@ public class ProloGraalInterpreterNode extends RootNode {
private final ProloGraalLanguage language;
private final ProloGraalContext context;
private final String returnStr = "return";
public ProloGraalInterpreterNode(ProloGraalLanguage language) {
super(language);
......
......@@ -22,10 +22,16 @@ import java.util.stream.IntStream;
@NodeInfo(shortName = "ProofTreeNode")
public class ProloGraalProofTreeNode extends Node {
private class LocalVariables{
public Deque<ProloGraalTerm<?>> goals;
public int start;
public List<ProloGraalClause> unifiableClauses;
}
private final Map<ProloGraalTerm<?>, List<ProloGraalClause>> clauses; // reference to the context clauses
//Stacks used to simulate a recursive call with a while loop
private final Stack<Deque<Integer>> branchesStack; // the goals of this node
private final Stack<LocalVariables> localVarsStack; // the goals of this node
private final Stack<Deque<ProloGraalTerm<?>>> goalsStack; // the goals of this node
private final Stack<Integer> startStack; // used to skip visited branches in case of redo
private final Stack<List<ProloGraalClause>> unifiableClausesStack; // store clauses that can resolve the current goal
......@@ -49,7 +55,7 @@ public class ProloGraalProofTreeNode extends Node {
Deque<ProloGraalTerm<?>> goals, boolean traceFlag) {
this.clauses = clauses;
this.traceFlag = traceFlag;
this.branchesStack = new Stack<>();
this.localVarsStack = new Stack<>();
this.goalsStack = new Stack<>();
goalsStack.push(goals);
this.startStack = new Stack<>();
......
......@@ -74,6 +74,8 @@ public final class ProloGraalRuntime {
ProloGraalClause leBuiltin = new ProloGraalLEBuiltin(context);
clauses.put(leBuiltin.getHead(), Collections.singletonList(leBuiltin));
ProloGraalClause realTimeBuiltin = new ProloGraalRealTimeBuiltin();
clauses.put(realTimeBuiltin.getHead(), Collections.singletonList(realTimeBuiltin));
}
public final Map<ProloGraalTerm<?>, List<ProloGraalClause>> getClauses() {
......
recommendedN(100000).
benchmark2(N, Time):-
benchmark(N),
benchmark(N),
benchmark(N),
benchmark(N),
real_time(A),
benchmark(N),
real_time(B),
is(C,'-'(B,A)),
'='(Time,C).
benchmark_text('time for N equal ').
benchmark_one:-
do_benchmark(100).
benchmark_two:-
do_benchmark(1000).
benchmark_three:-
do_benchmark(10000).
benchmark_four:-
do_benchmark(30000).
benchmark_five:-
do_benchmark(50000).
do_benchmark(N):-
benchmark_text(BenchText),
benchmark(N,Time),
write(BenchText), write(N), write(': '), write(Time).
benchmark(N, Time):-
real_time(A),
benchmark(N),
real_time(B),
is(C,'-'(B,A)),
'='(Time,C).
benchmark(0).
benchmark(N):-
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!