public static void main(String[] args) {
        int repeat = 1000;
        long start, duration, correct;
        double per;

        String processName = java.lang.management.ManagementFactory.getRuntimeMXBean().getName();
        String pidString = processName.substring(0, processName.indexOf('@'));
        pid = Integer.valueOf(pidString);

        // ETHAN (11/7/2018): If loading the native library does not have to succeed, why load?
        // org.voltdb.NativeLibraryLoader.loadVoltDB(false);

        // test the default fallback performance
        start = System.currentTimeMillis();
        correct = 0;
        for (int i = 0; i < repeat; i++) {
            long rss = PSScraper.getPSData(pid).rss;
            if (rss > 0) correct++;
        }
        duration = System.currentTimeMillis() - start;
        per = duration / (double) repeat;
        System.out.printf("%.2f ms per \"ps\" call / %d / %d correct\n",
                per, correct, repeat);

        // test linux procfs performance
        start = System.currentTimeMillis();
        correct = 0;
        for (int i = 0; i < repeat; i++) {
            long rss = getRSSFromProcFS();
            if (rss > 0) correct++;
        }
        duration = System.currentTimeMillis() - start;
        per = duration / (double) repeat;
        System.out.printf("%.2f ms per procfs read / %d / %d correct\n",
                per, correct, repeat);

        // test mac performance
        start = System.currentTimeMillis();
        correct = 0;
        for (int i = 0; i < repeat; i++) {
            long rss = ExecutionEngine.nativeGetRSS();
            if (rss > 0) correct++;
        }
        duration = System.currentTimeMillis() - start;
        per = duration / (double) repeat;
        System.out.printf("%.2f ms per ee.nativeGetRSS call / %d / %d correct\n",
                per, correct, repeat);
    }
public static void main ( String [ ] args ) { int repeat = 1000 ; long start , duration , correct ; double per ; String processName = java . lang . management . ManagementFactory . getRuntimeMXBean ( ) . getName ( ) ; String pidString = processName . substring ( 0 , processName . indexOf ( '@' ) ) ; pid = Integer . valueOf ( pidString ) ; start = System . currentTimeMillis ( ) ; correct = 0 ; for ( int i = 0 ; i < repeat ; i ++ ) { long rss = PSScraper . getPSData ( pid ) . rss ; if ( rss > 0 ) correct ++ ; } duration = System . currentTimeMillis ( ) - start ; per = duration / ( double ) repeat ; System . out . printf ( "%.2f ms per \"ps\" call / %d / %d correct\n" , per , correct , repeat ) ; start = System . currentTimeMillis ( ) ; correct = 0 ; for ( int i = 0 ; i < repeat ; i ++ ) { long rss = getRSSFromProcFS ( ) ; if ( rss > 0 ) correct ++ ; } duration = System . currentTimeMillis ( ) - start ; per = duration / ( double ) repeat ; System . out . printf ( "%.2f ms per procfs read / %d / %d correct\n" , per , correct , repeat ) ; start = System . currentTimeMillis ( ) ; correct = 0 ; for ( int i = 0 ; i < repeat ; i ++ ) { long rss = ExecutionEngine . nativeGetRSS ( ) ; if ( rss > 0 ) correct ++ ; } duration = System . currentTimeMillis ( ) - start ; per = duration / ( double ) repeat ; System . out . printf ( "%.2f ms per ee.nativeGetRSS call / %d / %d correct\n" , per , correct , repeat ) ; }
Manual performance testing code for getting stats.