简体   繁体   English

java testTimer测试执行时间

[英]java testTimer to test execution time

I have a function which checks the satiability of a logic expression also it shows the checking time. 我有一个检查逻辑表达式是否令人满意的函数,它还显示了检查时间。 I put an input example and it shows that it takes about 10000 milliseconds(10 sec) to run but why when I try to remove all the code lines associated with the testTimer it only took less than a second to run the code with the same input? 我放了一个输入示例,它显示运行大约需要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;}

The original code is available here: http://grepcode.com/file/repo1.maven.org/maven2/net.sourceforge.owlapi/jfact/1.0.0/uk/ac/manchester/cs/jfact/kernel/DlSatTester.java 原始代码位于此处: 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;}

You could try if this is faster (if that was what you were asking) 您可以尝试这样是否更快(如果那是您要的)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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