[英]java testTimer to test execution time
我有一個檢查邏輯表達式是否令人滿意的函數,它還顯示了檢查時間。 我放了一個輸入示例,它顯示運行大約需要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;}

原始代碼位於此處: http : //grepcode.com/file/repo1.maven.org/maven2/net.sourceforge.owlapi/jfact/1.0.0/uk/ac/manchester/cs/jfact/kernel/DlSatTester .java
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;}
您可以嘗試這樣是否更快(如果那是您要的)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.