简体   繁体   中英

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?

    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

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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