掲示板

A script in Liferay admin runs much slower that in terminal

thumbnail
7年前 に Charalampos Chrysikopoulos によって更新されました。

A script in Liferay admin runs much slower that in terminal

Junior Member 投稿: 79 参加年月日: 11/12/09 最新の投稿
Hello,

we noticed that running a groovy script (in Server administration) is much slower that running it as a java program in the terminal on the same machine. Why is that?

I got the scripts from here: http://www.ibm.com/developerworks/java/library/j-benchmark1/index.html

The groovy script is


 long t1 = System.nanoTime();

    int value = 0;
    for (int i = 0; i < 100 * 1000 * 1000; i++) {

        //L1: assert (value >= 0) : "should be positive";
        //L2: if (value < 0) throw new IllegalArgumentException("value = " + value + " < 0");

        global = value * 6;
        global += 3;
        global /= 2;
        value = value + 2;
    }

    long t2 = System.nanoTime();
    out.println("Execution time: " + ((t2 - t1) * 1e-6) + " milliseconds");


And the java code is here:


public class Benchmark {

    public static void main(String[] args) {

        long t1 = System.nanoTime();

        int value = 0;
        for (int i = 0; i < 100 * 1000 * 1000; i++) {

            //L1: assert (value >= 0) : "should be positive";
            //L2: if (value < 0) throw new IllegalArgumentException("value = " + value + " < 0");

            int global = value * 6;
            global += 3;
            global /= 2;
            value = value + 2;
        }

        long t2 = System.nanoTime();
        System.out.println("Execution time: " + ((t2 - t1) * 1e-6) + " milliseconds");

    }
}


Some example times:
- from the portal: 104333.702000 milliseconds
- from the terminal: 1.1039999999999999 milliseconds

Thank you in advance,
Harry