[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [GNU Crypto] performance issues
From: |
Raif S. Naffah |
Subject: |
Re: [GNU Crypto] performance issues |
Date: |
Mon, 28 Oct 2002 06:36:30 +1100 |
User-agent: |
KMail/1.4.3 |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: RIPEMD160
version #2:
- ----- begin Performance.java -----
public class Performance {
private static final int ROUNDS = 100000;
private static int R;
private static long T1 = 0;
private static long T2 = 0;
// default constructor
public static final void main(String[] args) {
Performance instance = new Performance();
instance.test1();
instance.test2();
}
/** comparing System.arraycopy to plain for loop. */
private void test1() {
byte[] dst = new byte[256];
byte[] src = new byte[256];
for (R = 0; R < 256; R++) {
src[R] = (byte) R;
}
T1 = -System.currentTimeMillis();
for (R = 0; R < ROUNDS; R++) {
for (int j = 0; j < 256; j++) {
dst[j] = src[j];
}
}
T1 += System.currentTimeMillis();
T2 = -System.currentTimeMillis();
for (R = 0; R < ROUNDS; R++) {
System.arraycopy(src, 0, dst, 0, 256);
}
T2 += System.currentTimeMillis();
System.out.println("*** Test #1: System.arraycopy / for loop");
System.out.println(" for loop: "+T1);
System.out.println(" arraycopy: "+T2);
}
/** comparing widening references. */
private void test2() {
byte[] dst = new byte[256];
byte[] srcBytes = new byte[256];
int[] srcInts = new int[256];
for (R = 0; R < 256; R++) {
srcBytes[R] = (byte) R;
srcInts[R] = R;
}
byte b = 0;
T1 = -System.currentTimeMillis();
for (R = 0; R < ROUNDS; R++) {
for (int j = 0; j < 256; j++) {
b = (byte)((srcBytes[j] & 0xFF) ^ (srcBytes[b & 0xFF] &
0xFF));
srcBytes[j] = b;
}
}
T1 += System.currentTimeMillis();
int t = 0;
T2 = -System.currentTimeMillis();
for (R = 0; R < ROUNDS; R++) {
for (int j = 0; j < 256; j++) {
t = srcBytes[j] ^ srcInts[t & 0xFF];
srcBytes[j] = (byte) t;
}
}
T2 += System.currentTimeMillis();
System.out.println("*** Test #2: Widening references");
System.out.println(" bytes only: "+T1);
System.out.println(" bytes+ints: "+T2);
}
}
- ----- end Performance.java -----
- ----- begin runit -----
#!/bin/sh
jikes -classpath /usr/java/jdk1.3.1_05/jre/lib/rt.jar:. \
-d classes src/Performance.java
echo "jikes+java..."
java -classpath classes Performance
echo
echo "jikes+gij..."
cd classes; gij Performance; cd ..
echo
gcj --main=Performance -o Performance src/Performance.java
echo "gcj (deault)..."
./Performance
echo
gcj -march=athlon-xp -O3 -fno-bounds-check \
--main=Performance -o Performance src/Performance.java
echo "gcj -march -O3 -fno-bounds-check..."
./Performance
echo
- ----- end runit -----
address@hidden perf]$ ./runit
jikes+java...
*** Test #1: System.arraycopy / for loop
for loop: 356
arraycopy: 25
*** Test #2: Widening references
bytes only: 312
bytes+ints: 234
jikes+gij...
*** Test #1: System.arraycopy / for loop
for loop: 4832
arraycopy: 64
*** Test #2: Widening references
bytes only: 10538
bytes+ints: 8908
gcj (deault)...
*** Test #1: System.arraycopy / for loop
for loop: 413
arraycopy: 18
*** Test #2: Widening references
bytes only: 750
bytes+ints: 611
gcj -march -O3 -fno-bounds-check...
*** Test #1: System.arraycopy / for loop
for loop: 53
arraycopy: 18
*** Test #2: Widening references
bytes only: 113
bytes+ints: 120
cheers;
rsn
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)
Comment: Que du magnifique
iD8DBQE9vEBG+e1AKnsTRiERAxUPAKDxGudjsuXovW+WRCnUqFLGVum1RQCg7Mz8
pKs/35CnLCreFPmaj7tBI4s=
=NlbY
-----END PGP SIGNATURE-----