繁体   English   中英

java testTimer测试执行时间

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM