我有一个检查逻辑表达式的可用性的函数,它还显示了检查时间。我输入一个输入示例,它显示运行大约需要10000毫秒(10秒),但是为什么当我尝试删除与testTimer关联的所有代码行时,只需不到一秒的时间来运行具有相同输入的代码?
protected boolean runSat() {
testTimer.start();
boolean result = checkSatisfiability();
testTimer.stop();
 options.getLog().print("\nChecking time was ", testTimer.getResultTim e()," milliseconds");
testTimer.reset();
finaliseStatistic();
if (result) {cGraph.print(options.getLog());}return result;}

答案 0 :(得分:0)
protected boolean runSat() {
long startTime = System.nanoTime();
boolean result = checkSatisfiability();
long endTime = System.nanoTime();
 options.getLog().print("\nChecking time was ", (endTime - startTime)/1000000," milliseconds");
testTimer.reset();
finaliseStatistic();
if (result) {cGraph.print(options.getLog());}return result;}
你可以试试这是否更快(如果那是你要的)