简体   繁体   中英

Does /usr/bin/time include post program garbage collection for a java program?

I'm writing a benchmark matrix multiplication program implemented in both Java and C++. I'd like to reduce the influence of garbage collection on the Java program timings in order to match the C++ version as closely as possible.

To this end, I've made the matrix arrays final static members of the main class that I presume will be collected after my program thread finishes execution.

public class MatMult {
    public static final int m1[][] = new int[BIGNUM][BIGNUM];
    //  ... repeat

    public static void main() {
        //  ... do fun maths
    }
}

When I time these ( /usr/bin/time java MatMult ), will the timings include time taken to clean up the static members after MatMult completes execution? (I'm under the impression that the cleanup is done by the separate JVM thread at this time)

As a general rule the Java Runtime Environment doesn't perform garbage collection on exit. Of more immediate concern would be the performance costs of JIT and of course trying to Write Dumb Code . Also, the signature of main() takes a String[] like

public static void main(String[] args) {

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