Re: Gcj binaries performance (arm-linux)

"ffileppo" <[email protected]>
Newsgroups gmane.comp.gcc.java.devel
Message-ID <[email protected]>
> > I'm quite surprised of this result, I thought that a binary compiled with gcj would be much faster than a java virtual machine.
>
> So would I.
>
> > I've also tried to pass some options (e.g. -march=, -mtune, -mcpu...) when compiling with gcj but results are not changing.
> >
> > Any idea to improve performance?
>
> Without seeing your code, it's impossible to say.  I don't want
> to speculate.
>
> Andrew.
>


Hi Andrew,
thanks for your interest. Here is the code:

public final class MyPanel {


  private static final int NUM_ELEMENTS = 1000;
  public static final int NUM_LOOP = 100;

  public MyPanel(){}

  public static void main(String args[]) {
    MyPanel mp = new MyPanel();
    mp.sortArray();
  }

  private void sortArray() {
    System.out.println("Test \"Bubble Sort\" (Num loop: " + NUM_LOOP + ")");
    int[] array = new int[NUM_ELEMENTS];
    int l = 0, i = 0;

    long sysTime = System.currentTimeMillis();

    for (l = 0; l < NUM_LOOP; l++) {
      for (i = 0; i < NUM_ELEMENTS; i++) {
        array[i] = NUM_ELEMENTS - i;
      }
      BubbleSort(array, NUM_ELEMENTS);
      if(l == 0)
        System.out.println("First loop time: " + (System.currentTimeMillis() - sysTime));
    }
    System.out.println("Total time elapsed: " + (System.currentTimeMillis() - sysTime));
  }

  private void BubbleSort(int array[], int elemN) {
    int i, tmp;
    int alto = elemN;

    while (alto > 0) {
      for (i = 0; i < alto - 1; i++) {
        if (array[i] > array[i + 1]) {
          tmp = array[i];
          array[i] = array[i + 1];
          array[i + 1] = tmp;
        }
      }
      alto--;
    }
  }

}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.