Benchmark: ArrayList<Integer>, Integer[], int[]

CroniD

Aktives Mitglied
Morgen,

gerade hat mich ein Kommilitone gefragt, ob eine ArrayList<Integer> gegenüber einem int oder Integer Array signifikate Nachteile mit sich bringt. Pauschal habe ich erstmal gesagt, dass ein int Array theoretisch schneller erzeugt und befüllt werden könne als ein Integer Array oder eine ArrayList<Integer>. Na ja, ich habe dann fix ein Benchmark geschrieben und war doch etwas verblüfft.

Als VM Parameter habe ich "-client -Xms768m -Xmx768m -verbose:gc" benutzt (-server ist nicht viel anders), eine Oracle 32-bit JRE 6u24 und als CPU einen AMD Turion64 X2 (2 CPU Kerne).

Hier der Code für meine Benchmark Klasse:
Java:
public class IntegerTests {

	private static Runtime rt = Runtime.getRuntime();
	
	public static void main(String[] args) {
		long max = rt.maxMemory(),
			total = rt.totalMemory(),
			free = rt.freeMemory(),
			used = total - free;
		System.out.println("CPUs: "+rt.availableProcessors()
				+"\nMaxMemory (in byte): "+max
				+"\nTotalMemory (in byte): "+total
				+"\nFreeMemory (in byte): "+free
				+"\nUsedMemory (in byte): "+used);
		int benchmarkLoop = 10, elementLoop = 10000000;
		long start = 0;
		
		for (int z = 1; z <= benchmarkLoop; z++) {
			System.out.println("\nRUN "+z);
			start = System.currentTimeMillis();
			List<Integer> list = new ArrayList<Integer>(elementLoop);
			for (int i = 0; i < list.size(); i++){
				list.add(i); // Autoboxing
			}
			printResult("list", start);
			
			start = System.currentTimeMillis();
			Integer[] integerA = new Integer[elementLoop];
			for (int i = 0; i < integerA.length; i++) {
				integerA[i] = i; // Autoboxing
			}
			printResult("integer array", start);
			
			start = System.currentTimeMillis();
			int[] intA = new int[elementLoop];
			for (int i = 0; i < intA.length; i++){
				intA[i] = i;
			}
			printResult("int array", start);
		}
	}
	
	private static void printResult(String id, long start) {
		long result = System.currentTimeMillis() - start;
		System.out.println("\tTime ("+id+"): "+result+" ms");
		System.out.print("\t\tRun GC: ");
		System.gc();
		System.out.println("\t\tGC END");
	}
}

Der Output:
Code:
CPUs: 2
MaxMemory (in byte): 778502144
TotalMemory (in byte): 778502144
FreeMemory (in byte): 774205584
UsedMemory (in byte): 4296560

RUN 1
	Time (list): 55 ms
		Run GC: [Full GC 43258K->39182K(760256K), 0.1318455 secs]
		GC END
	Time (integer array): 344 ms
		Run GC: [Full GC 237687K->125K(760256K), 0.0983542 secs]
		GC END
	Time (int array): 62 ms
		Run GC: [Full GC 42971K->125K(760256K), 0.0083771 secs]
		GC END

RUN 2
	Time (list): 30 ms
		Run GC: [Full GC 42971K->125K(760256K), 0.0106661 secs]
		GC END
	Time (integer array): 206 ms
		Run GC: [Full GC 198073K->125K(760256K), 0.1107050 secs]
		GC END
	Time (int array): 62 ms
		Run GC: [Full GC 42825K->125K(760256K), 0.0079840 secs]
		GC END

RUN 3
	Time (list): 30 ms
		Run GC: [Full GC 42825K->125K(760256K), 0.0085653 secs]
		GC END
	Time (integer array): 209 ms
		Run GC: [Full GC 195608K->125K(760256K), 0.1023137 secs]
		GC END
	Time (int array): 68 ms
		Run GC: [Full GC 42727K->125K(760256K), 0.0084573 secs]
		GC END

RUN 4
	Time (list): 27 ms
		Run GC: [Full GC 42727K->125K(760256K), 0.0083546 secs]
		GC END
	Time (integer array): 207 ms
		Run GC: [Full GC 198469K->125K(760256K), 0.1033306 secs]
		GC END
	Time (int array): 65 ms
		Run GC: [Full GC 42667K->125K(760256K), 0.0081224 secs]
		GC END

RUN 5
	Time (list): 28 ms
		Run GC: [Full GC 42667K->125K(760256K), 0.0097044 secs]
		GC END
	Time (integer array): 206 ms
		Run GC: [Full GC 195790K->125K(760256K), 0.1003557 secs]
		GC END
	Time (int array): 64 ms
		Run GC: [Full GC 42625K->125K(760256K), 0.0090278 secs]
		GC END

RUN 6
	Time (list): 28 ms
		Run GC: [Full GC 42625K->125K(760256K), 0.0097856 secs]
		GC END
	Time (integer array): 206 ms
		Run GC: [Full GC 197308K->125K(760256K), 0.0992156 secs]
		GC END
	Time (int array): 62 ms
		Run GC: [Full GC 42599K->125K(760256K), 0.0080075 secs]
		GC END

RUN 7
	Time (list): 30 ms
		Run GC: [Full GC 42599K->125K(760256K), 0.0094942 secs]
		GC END
	Time (integer array): 214 ms
		Run GC: [Full GC 196136K->125K(760256K), 0.1047523 secs]
		GC END
	Time (int array): 74 ms
		Run GC: [Full GC 42581K->125K(760256K), 0.0094507 secs]
		GC END

RUN 8
	Time (list): 28 ms
		Run GC: [Full GC 42581K->125K(760256K), 0.0084456 secs]
		GC END
	Time (integer array): 211 ms
		Run GC: [Full GC 198688K->125K(760256K), 0.1003885 secs]
		GC END
	Time (int array): 63 ms
		Run GC: [Full GC 42573K->125K(760256K), 0.0085580 secs]
		GC END

RUN 9
	Time (list): 28 ms
		Run GC: [Full GC 42573K->125K(760256K), 0.0107116 secs]
		GC END
	Time (integer array): 213 ms
		Run GC: [Full GC 198306K->125K(760256K), 0.1009228 secs]
		GC END
	Time (int array): 63 ms
		Run GC: [Full GC 42567K->125K(760256K), 0.0086949 secs]
		GC END

RUN 10
	Time (list): 30 ms
		Run GC: [Full GC 42567K->125K(760256K), 0.0096326 secs]
		GC END
	Time (integer array): 208 ms
		Run GC: [Full GC 198032K->125K(760256K), 0.1002193 secs]
		GC END
	Time (int array): 64 ms
		Run GC: [Full GC 42563K->125K(760256K), 0.0100442 secs]
		GC END
Platzierung:
  1. ArrayList<Integer>
  2. int[] (fast immer doppelt soviel wie eine ArrayList<Integer>)
  3. Integer[] (ziemlich abgeschlagen)

Habe ich einen Fehler beim Benchmark gemacht?
Oder stimmen die Ergebnisse und wenn ja, warum? :rtfm:
Kann jemand Vergleichswerte posten? ???:L
 
Zuletzt bearbeitet:

CroniD

Aktives Mitglied
Ich habe den Code nochmal überarbeitet:
Java:
public class IntegerTests {

	private static int benchmarkLoop = 20, elementLoop = 10000000;
	
	private static Runtime rt = Runtime.getRuntime();
	private static long start;
	private static String listID = "ArrayList";
	private static String integerArrayID = "Integer Array";
	private static String intArrayID = "int Array";
	@SuppressWarnings("rawtypes")
	private static List[] results = {
		new ArrayList<Long>(benchmarkLoop), // results of ArrayList<Integer>
		new ArrayList<Long>(benchmarkLoop), // results of Integer[]
		new ArrayList<Long>(benchmarkLoop)  // results of int[]
	};
	
	public static void main(String[] args) {
		printSystem();
		doGC();
		for (int z = 1; z <= benchmarkLoop; z++) {
			System.out.println("\nRUN "+z);
			start = System.currentTimeMillis();
			List<Integer> list = new ArrayList<Integer>(elementLoop);
			for (int i = 0; i < list.size(); i++){
				list.add(i); // Autoboxing
			}
			printResult(listID, start);
			
			start = System.currentTimeMillis();
			Integer[] integerA = new Integer[elementLoop];
			for (int i = 0; i < integerA.length; i++) {
				integerA[i] = i; // Autoboxing
			}
			printResult(integerArrayID, start);
			
			start = System.currentTimeMillis();
			int[] intA = new int[elementLoop];
			for (int i = 0; i < intA.length; i++){
				intA[i] = i;
			}
			printResult(intArrayID, start);
		}
		printResults();
	}
	
	private static void printResults() {
		System.out.println();
		printSystem();
		System.out.println("\nEND RESULTS");
		for (int i = 0; i < results.length; i++) {
			long result = 0;
			for (int j = 0; j < results[i].size(); j++) {
				result += (Long) results[i].get(j);
			}
			result = result / results[i].size();
			if (i == 0) {
				System.out.println("\tAverage Time ("+listID+"): "+result+" ms");
			} else if (i == 1) {
				System.out.println("\tAverage Time ("+integerArrayID+"): "+result+" ms");
			} else if (i == 2) {
				System.out.println("\tAverage Time ("+intArrayID+"): "+result+" ms");
			}
			
		}
	}
	
	private static void printSystem() {
		System.out.println("SYSTEM");
		System.out.println("\tOS: "+System.getProperty("os.name")
				+" ("+System.getProperty("os.version")
				+", "+System.getProperty("sun.os.patch.level")+")");
		System.out.println("\tJava Version: "+System.getProperty("java.vm.name")
				+" "+System.getProperty("java.runtime.version")
				+" ("+System.getProperty("java.vendor")+")");
		System.out.println("\tArch: "+System.getProperty("os.arch"));
		long max = rt.maxMemory(),
		total = rt.totalMemory(),
		free = rt.freeMemory(),
		used = total - free;
		System.out.println("\tCPUs: "+rt.availableProcessors()
			+"\n\tMaxMemory (in byte): "+max
			+"\n\tTotalMemory (in byte): "+total
			+"\n\tFreeMemory (in byte): "+free
			+"\n\tUsedMemory (in byte): "+used);
		System.out.println("\n\tBenchmarkLoop: "+benchmarkLoop+"\n\tElementLoop: "+elementLoop);
	}
	
	private static void doGC() {
		System.out.print("\tRun GC: ");
		System.gc();
	}
	
	@SuppressWarnings("unchecked")
	private static void printResult(String id, long start) {
		long result = System.currentTimeMillis() - start;
		if (id == listID) {
			results[0].add(result);
		} else if (id == integerArrayID) {
			results[1].add(result);
		} else if (id == intArrayID) {
			results[2].add(result);
		}
		System.out.println("\tTime ("+id+"): "+result+" ms");
		doGC();
	}
}

Output mit VM Parameter "-client -Xms768m -Xmx768m -verbose:gc":
Code:
SYSTEM
	OS: Windows Vista (6.0, Service Pack 2)
	Java Version: Java HotSpot(TM) Client VM 1.6.0_24-b07 (Sun Microsystems Inc.)
	Arch: x86
	CPUs: 2
	MaxMemory (in byte): 778502144
	TotalMemory (in byte): 778502144
	FreeMemory (in byte): 774205584
	UsedMemory (in byte): 4296560

	BenchmarkLoop: 20
	ElementLoop: 10000000
	Run GC: [Full GC 4195K->120K(760256K), 0.0097978 secs]

RUN 1
	Time (ArrayList): 46 ms
	Run GC: [Full GC 43379K->39188K(760256K), 0.1230274 secs]
	Time (Integer Array): 358 ms
	Run GC: [Full GC 237692K->130K(760256K), 0.0996194 secs]
	Time (int Array): 65 ms
	Run GC: [Full GC 42976K->130K(760256K), 0.0113823 secs]

RUN 2
	Time (ArrayList): 27 ms
	Run GC: [Full GC 42976K->130K(760256K), 0.0083351 secs]
	Time (Integer Array): 194 ms
	Run GC: [Full GC 198079K->130K(760256K), 0.0999049 secs]
	Time (int Array): 64 ms
	Run GC: [Full GC 42830K->130K(760256K), 0.0095607 secs]

RUN 3
	Time (ArrayList): 29 ms
	Run GC: [Full GC 42830K->130K(760256K), 0.0080657 secs]
	Time (Integer Array): 192 ms
	Run GC: [Full GC 195614K->130K(760256K), 0.0974757 secs]
	Time (int Array): 62 ms
	Run GC: [Full GC 42732K->130K(760256K), 0.0093153 secs]

RUN 4
	Time (ArrayList): 29 ms
	Run GC: [Full GC 42732K->130K(760256K), 0.0080818 secs]
	Time (Integer Array): 191 ms
	Run GC: [Full GC 198474K->130K(760256K), 0.0990557 secs]
	Time (int Array): 76 ms
	Run GC: [Full GC 42673K->130K(760256K), 0.0096106 secs]

RUN 5
	Time (ArrayList): 29 ms
	Run GC: [Full GC 42673K->130K(760256K), 0.0081806 secs]
	Time (Integer Array): 194 ms
	Run GC: [Full GC 195796K->130K(760256K), 0.1009507 secs]
	Time (int Array): 64 ms
	Run GC: [Full GC 42630K->130K(760256K), 0.0093124 secs]

RUN 6
	Time (ArrayList): 28 ms
	Run GC: [Full GC 42630K->130K(760256K), 0.0082094 secs]
	Time (Integer Array): 191 ms
	Run GC: [Full GC 197313K->130K(760256K), 0.1000105 secs]
	Time (int Array): 67 ms
	Run GC: [Full GC 42605K->130K(760256K), 0.0098521 secs]

RUN 7
	Time (ArrayList): 30 ms
	Run GC: [Full GC 42605K->130K(760256K), 0.0090518 secs]
	Time (Integer Array): 197 ms
	Run GC: [Full GC 196142K->130K(760256K), 0.0995564 secs]
	Time (int Array): 65 ms
	Run GC: [Full GC 42586K->130K(760256K), 0.0088782 secs]

RUN 8
	Time (ArrayList): 29 ms
	Run GC: [Full GC 42586K->130K(760256K), 0.0081371 secs]
	Time (Integer Array): 201 ms
	Run GC: [Full GC 198694K->130K(760256K), 0.1018752 secs]
	Time (int Array): 62 ms
	Run GC: [Full GC 42578K->130K(760256K), 0.0090552 secs]

RUN 9
	Time (ArrayList): 32 ms
	Run GC: [Full GC 42578K->130K(760256K), 0.0087873 secs]
	Time (Integer Array): 190 ms
	Run GC: [Full GC 198312K->130K(760256K), 0.0994825 secs]
	Time (int Array): 63 ms
	Run GC: [Full GC 42572K->130K(760256K), 0.0085409 secs]

RUN 10
	Time (ArrayList): 33 ms
	Run GC: [Full GC 42572K->130K(760256K), 0.0088200 secs]
	Time (Integer Array): 194 ms
	Run GC: [Full GC 198037K->130K(760256K), 0.0998565 secs]
	Time (int Array): 65 ms
	Run GC: [Full GC 42568K->130K(760256K), 0.0092977 secs]

RUN 11
	Time (ArrayList): 28 ms
	Run GC: [Full GC 42568K->130K(760256K), 0.0085790 secs]
	Time (Integer Array): 197 ms
	Run GC: [Full GC 197840K->130K(760256K), 0.0979474 secs]
	Time (int Array): 61 ms
	Run GC: [Full GC 42565K->130K(760256K), 0.0092297 secs]

RUN 12
	Time (ArrayList): 28 ms
	Run GC: [Full GC 42565K->130K(760256K), 0.0086744 secs]
	Time (Integer Array): 192 ms
	Run GC: [Full GC 197698K->130K(760256K), 0.1002437 secs]
	Time (int Array): 64 ms
	Run GC: [Full GC 42563K->130K(760256K), 0.0081737 secs]

RUN 13
	Time (ArrayList): 28 ms
	Run GC: [Full GC 42563K->130K(760256K), 0.0092014 secs]
	Time (Integer Array): 205 ms
	Run GC: [Full GC 197596K->130K(760256K), 0.1004862 secs]
	Time (int Array): 63 ms
	Run GC: [Full GC 42562K->130K(760256K), 0.0084133 secs]

RUN 14
	Time (ArrayList): 28 ms
	Run GC: [Full GC 42562K->130K(760256K), 0.0089437 secs]
	Time (Integer Array): 198 ms
	Run GC: [Full GC 197523K->130K(760256K), 0.0992322 secs]
	Time (int Array): 64 ms
	Run GC: [Full GC 42560K->130K(760256K), 0.0108499 secs]

RUN 15
	Time (ArrayList): 27 ms
	Run GC: [Full GC 42560K->130K(760256K), 0.0088645 secs]
	Time (Integer Array): 194 ms
	Run GC: [Full GC 197470K->130K(760256K), 0.1018801 secs]
	Time (int Array): 65 ms
	Run GC: [Full GC 42560K->130K(760256K), 0.0086328 secs]

RUN 16
	Time (ArrayList): 29 ms
	Run GC: [Full GC 42560K->130K(760256K), 0.0083835 secs]
	Time (Integer Array): 196 ms
	Run GC: [Full GC 197432K->130K(760256K), 0.1007424 secs]
	Time (int Array): 64 ms
	Run GC: [Full GC 42559K->130K(760256K), 0.0101000 secs]

RUN 17
	Time (ArrayList): 29 ms
	Run GC: [Full GC 42559K->130K(760256K), 0.0083483 secs]
	Time (Integer Array): 198 ms
	Run GC: [Full GC 197405K->130K(760256K), 0.0977817 secs]
	Time (int Array): 62 ms
	Run GC: [Full GC 42559K->130K(760256K), 0.0089550 secs]

RUN 18
	Time (ArrayList): 29 ms
	Run GC: [Full GC 42559K->130K(760256K), 0.0085785 secs]
	Time (Integer Array): 192 ms
	Run GC: [Full GC 197385K->130K(760256K), 0.0993628 secs]
	Time (int Array): 67 ms
	Run GC: [Full GC 42558K->130K(760256K), 0.0093578 secs]

RUN 19
	Time (ArrayList): 28 ms
	Run GC: [Full GC 42558K->130K(760256K), 0.0086748 secs]
	Time (Integer Array): 195 ms
	Run GC: [Full GC 197371K->130K(760256K), 0.0985478 secs]
	Time (int Array): 63 ms
	Run GC: [Full GC 42558K->130K(760256K), 0.0099596 secs]

RUN 20
	Time (ArrayList): 32 ms
	Run GC: [Full GC 42558K->130K(760256K), 0.0089740 secs]
	Time (Integer Array): 194 ms
	Run GC: [Full GC 197361K->130K(760256K), 0.0985669 secs]
	Time (int Array): 68 ms
	Run GC: [Full GC 42558K->130K(760256K), 0.0095671 secs]

SYSTEM
	OS: Windows Vista (6.0, Service Pack 2)
	Java Version: Java HotSpot(TM) Client VM 1.6.0_24-b07 (Sun Microsystems Inc.)
	Arch: x86
	CPUs: 2
	MaxMemory (in byte): 778502144
	TotalMemory (in byte): 778502144
	FreeMemory (in byte): 774921952
	UsedMemory (in byte): 3580192

	BenchmarkLoop: 20
	ElementLoop: 10000000

END RESULTS
	Average Time (ArrayList): 29 ms
	Average Time (Integer Array): 203 ms
	Average Time (int Array): 64 ms

Mich würde wirklich interessieren, wie der Output bei anderen aussieht und warum die Ergebnisse so sind wie sie sind. ???:L
 

Ducksoul

Mitglied
Code:
SYSTEM
	OS: Linux (2.6.38-2-amd64, unknown)
	Java Version: Java HotSpot(TM) 64-Bit Server VM 1.6.0_24-b07 (Sun Microsystems Inc.)
	Arch: amd64
	CPUs: 4
	MaxMemory (in byte): 771751936
	TotalMemory (in byte): 771751936
	FreeMemory (in byte): 767725392
	UsedMemory (in byte): 4026544

	BenchmarkLoop: 20
	ElementLoop: 10000000
	Run GC: [GC 3932K->192K(753664K), 0.0026840 secs]
[Full GC 192K->122K(753664K), 0.0077170 secs]

RUN 1
	Time (ArrayList): 21 ms
	Run GC: [GC 43117K->39281K(753664K), 0.0697180 secs]
[Full GC 39281K->39192K(753664K), 0.0259640 secs]
	Time (Integer Array): 133 ms
	Run GC: [GC 235541K->39224K(753664K), 0.0156910 secs]
[Full GC 39224K->134K(753664K), 0.0050310 secs]
	Time (int Array): 29 ms
	Run GC: [GC 42738K->134K(753664K), 0.0002700 secs]
[Full GC 134K->134K(753664K), 0.0056580 secs]

RUN 2
	Time (ArrayList): 9 ms
	Run GC: [GC 42738K->39229K(753664K), 0.0516710 secs]
[Full GC 39229K->39197K(753664K), 0.0238460 secs]
	Time (Integer Array): 80 ms
	Run GC: [GC 235805K->39197K(753664K), 0.0053210 secs]
[Full GC 39197K->134K(753664K), 0.0063850 secs]
	Time (int Array): 25 ms
	Run GC: [GC 42614K->134K(753664K), 0.0002580 secs]
[Full GC 134K->134K(753664K), 0.0075510 secs]

RUN 3
	Time (ArrayList): 10 ms
	Run GC: [GC 42614K->134K(753664K), 0.0002890 secs]
[Full GC 134K->134K(753664K), 0.0089960 secs]
	Time (Integer Array): 70 ms
	Run GC: [GC 196383K->134K(753664K), 0.0004050 secs]
[Full GC 134K->134K(753664K), 0.0057620 secs]
	Time (int Array): 28 ms
	Run GC: [GC 42520K->134K(753664K), 0.0003280 secs]
[Full GC 134K->134K(753664K), 0.0055050 secs]

RUN 4
	Time (ArrayList): 8 ms
	Run GC: [GC 42520K->134K(753664K), 0.0001970 secs]
[Full GC 134K->134K(753664K), 0.0056750 secs]
	Time (Integer Array): 68 ms
	Run GC: [GC 196742K->134K(753664K), 0.0002650 secs]
[Full GC 134K->134K(753664K), 0.0058730 secs]
	Time (int Array): 25 ms
	Run GC: [GC 42474K->134K(753664K), 0.0002400 secs]
[Full GC 134K->134K(753664K), 0.0057820 secs]

RUN 5
	Time (ArrayList): 8 ms
	Run GC: [GC 42474K->134K(753664K), 0.0001510 secs]
[Full GC 134K->134K(753664K), 0.0052360 secs]
	Time (Integer Array): 69 ms
	Run GC: [GC 196488K->134K(753664K), 0.0002730 secs]
[Full GC 134K->134K(753664K), 0.0050570 secs]
	Time (int Array): 26 ms
	Run GC: [GC 42429K->134K(753664K), 0.0002960 secs]
[Full GC 134K->134K(753664K), 0.0050730 secs]

RUN 6
	Time (ArrayList): 8 ms
	Run GC: [GC 42429K->134K(753664K), 0.0003820 secs]
[Full GC 134K->134K(753664K), 0.0049020 secs]
	Time (Integer Array): 66 ms
	Run GC: [GC 196742K->134K(753664K), 0.0003330 secs]
[Full GC 134K->134K(753664K), 0.0054510 secs]
	Time (int Array): 25 ms
	Run GC: [GC 42407K->134K(753664K), 0.0001690 secs]
[Full GC 134K->134K(753664K), 0.0058800 secs]

RUN 7
	Time (ArrayList): 9 ms
	Run GC: [GC 42407K->134K(753664K), 0.0002320 secs]
[Full GC 134K->134K(753664K), 0.0049410 secs]
	Time (Integer Array): 68 ms
	Run GC: [GC 196478K->134K(753664K), 0.0002340 secs]
[Full GC 134K->134K(753664K), 0.0053810 secs]
	Time (int Array): 26 ms
	Run GC: [GC 42386K->134K(753664K), 0.0001510 secs]
[Full GC 134K->134K(753664K), 0.0060920 secs]

RUN 8
	Time (ArrayList): 9 ms
	Run GC: [GC 42386K->134K(753664K), 0.0001650 secs]
[Full GC 134K->134K(753664K), 0.0062560 secs]
	Time (Integer Array): 67 ms
	Run GC: [GC 195449K->134K(753664K), 0.0003370 secs]
[Full GC 134K->134K(753664K), 0.0060770 secs]
	Time (int Array): 26 ms
	Run GC: [GC 42371K->134K(753664K), 0.0001600 secs]
[Full GC 134K->134K(753664K), 0.0053750 secs]

RUN 9
	Time (ArrayList): 8 ms
	Run GC: [GC 42371K->134K(753664K), 0.0001530 secs]
[Full GC 134K->134K(753664K), 0.0068620 secs]
	Time (Integer Array): 66 ms
	Run GC: [GC 196742K->134K(753664K), 0.0002620 secs]
[Full GC 134K->134K(753664K), 0.0069630 secs]
	Time (int Array): 26 ms
	Run GC: [GC 42371K->134K(753664K), 0.0002120 secs]
[Full GC 134K->134K(753664K), 0.0060160 secs]

RUN 10
	Time (ArrayList): 9 ms
	Run GC: [GC 42371K->134K(753664K), 0.0008640 secs]
[Full GC 134K->134K(753664K), 0.0067860 secs]
	Time (Integer Array): 66 ms
	Run GC: [GC 196742K->134K(753664K), 0.0002590 secs]
[Full GC 134K->134K(753664K), 0.0077130 secs]
	Time (int Array): 24 ms
	Run GC: [GC 42371K->134K(753664K), 0.0002080 secs]
[Full GC 134K->134K(753664K), 0.0054410 secs]

RUN 11
	Time (ArrayList): 7 ms
	Run GC: [GC 42371K->134K(753664K), 0.0001630 secs]
[Full GC 134K->134K(753664K), 0.0057260 secs]
	Time (Integer Array): 70 ms
	Run GC: [GC 196742K->134K(753664K), 0.0003570 secs]
[Full GC 134K->134K(753664K), 0.0048900 secs]
	Time (int Array): 25 ms
	Run GC: [GC 42371K->134K(753664K), 0.0001570 secs]
[Full GC 134K->134K(753664K), 0.0070100 secs]

RUN 12
	Time (ArrayList): 8 ms
	Run GC: [GC 42371K->134K(753664K), 0.0002100 secs]
[Full GC 134K->134K(753664K), 0.0076700 secs]
	Time (Integer Array): 64 ms
	Run GC: [GC 196742K->134K(753664K), 0.0002270 secs]
[Full GC 134K->134K(753664K), 0.0052300 secs]
	Time (int Array): 25 ms
	Run GC: [GC 42371K->134K(753664K), 0.0001770 secs]
[Full GC 134K->134K(753664K), 0.0049620 secs]

RUN 13
	Time (ArrayList): 7 ms
	Run GC: [GC 42371K->134K(753664K), 0.0001490 secs]
[Full GC 134K->134K(753664K), 0.0066220 secs]
	Time (Integer Array): 66 ms
	Run GC: [GC 196742K->134K(753664K), 0.0002790 secs]
[Full GC 134K->134K(753664K), 0.0051890 secs]
	Time (int Array): 25 ms
	Run GC: [GC 42371K->134K(753664K), 0.0001600 secs]
[Full GC 134K->134K(753664K), 0.0073960 secs]

RUN 14
	Time (ArrayList): 10 ms
	Run GC: [GC 42371K->134K(753664K), 0.0004400 secs]
[Full GC 134K->134K(753664K), 0.0104080 secs]
	Time (Integer Array): 63 ms
	Run GC: [GC 196742K->134K(753664K), 0.0003890 secs]
[Full GC 134K->134K(753664K), 0.0085520 secs]
	Time (int Array): 26 ms
	Run GC: [GC 42371K->134K(753664K), 0.0002510 secs]
[Full GC 134K->134K(753664K), 0.0049400 secs]

RUN 15
	Time (ArrayList): 8 ms
	Run GC: [GC 42371K->134K(753664K), 0.0001680 secs]
[Full GC 134K->134K(753664K), 0.0113540 secs]
	Time (Integer Array): 68 ms
	Run GC: [GC 196742K->134K(753664K), 0.0002990 secs]
[Full GC 134K->134K(753664K), 0.0050470 secs]
	Time (int Array): 26 ms
	Run GC: [GC 42371K->134K(753664K), 0.0002160 secs]
[Full GC 134K->134K(753664K), 0.0084590 secs]

RUN 16
	Time (ArrayList): 9 ms
	Run GC: [GC 42371K->134K(753664K), 0.0001800 secs]
[Full GC 134K->134K(753664K), 0.0068390 secs]
	Time (Integer Array): 65 ms
	Run GC: [GC 196742K->134K(753664K), 0.0002100 secs]
[Full GC 134K->134K(753664K), 0.0057890 secs]
	Time (int Array): 28 ms
	Run GC: [GC 42371K->134K(753664K), 0.0002520 secs]
[Full GC 134K->134K(753664K), 0.0078800 secs]

RUN 17
	Time (ArrayList): 8 ms
	Run GC: [GC 42371K->134K(753664K), 0.0001530 secs]
[Full GC 134K->134K(753664K), 0.0060760 secs]
	Time (Integer Array): 66 ms
	Run GC: [GC 196742K->134K(753664K), 0.0002330 secs]
[Full GC 134K->134K(753664K), 0.0069680 secs]
	Time (int Array): 25 ms
	Run GC: [GC 42371K->134K(753664K), 0.0002150 secs]
[Full GC 134K->134K(753664K), 0.0067390 secs]

RUN 18
	Time (ArrayList): 8 ms
	Run GC: [GC 42371K->134K(753664K), 0.0001810 secs]
[Full GC 134K->134K(753664K), 0.0053610 secs]
	Time (Integer Array): 66 ms
	Run GC: [GC 196742K->134K(753664K), 0.0003570 secs]
[Full GC 134K->134K(753664K), 0.0121110 secs]
	Time (int Array): 25 ms
	Run GC: [GC 42371K->134K(753664K), 0.0001590 secs]
[Full GC 134K->134K(753664K), 0.0049420 secs]

RUN 19
	Time (ArrayList): 7 ms
	Run GC: [GC 42371K->134K(753664K), 0.0001420 secs]
[Full GC 134K->134K(753664K), 0.0058960 secs]
	Time (Integer Array): 65 ms
	Run GC: [GC 196742K->134K(753664K), 0.0002700 secs]
[Full GC 134K->134K(753664K), 0.0069200 secs]
	Time (int Array): 25 ms
	Run GC: [GC 42371K->134K(753664K), 0.0002320 secs]
[Full GC 134K->134K(753664K), 0.0066170 secs]

RUN 20
	Time (ArrayList): 8 ms
	Run GC: [GC 42371K->134K(753664K), 0.0003540 secs]
[Full GC 134K->134K(753664K), 0.0086140 secs]
	Time (Integer Array): 66 ms
	Run GC: [GC 196742K->134K(753664K), 0.0008950 secs]
[Full GC 134K->134K(753664K), 0.0049380 secs]
	Time (int Array): 26 ms
	Run GC: [GC 42371K->134K(753664K), 0.0001660 secs]
[Full GC 134K->134K(753664K), 0.0049780 secs]

SYSTEM
	OS: Linux (2.6.38-2-amd64, unknown)
	Java Version: Java HotSpot(TM) 64-Bit Server VM 1.6.0_24-b07 (Sun Microsystems Inc.)
	Arch: amd64
	CPUs: 4
	MaxMemory (in byte): 771751936
	TotalMemory (in byte): 771751936
	FreeMemory (in byte): 768363696
	UsedMemory (in byte): 3388240

	BenchmarkLoop: 20
	ElementLoop: 10000000

END RESULTS
	Average Time (ArrayList): 8 ms
	Average Time (Integer Array): 70 ms
	Average Time (int Array): 25 ms

Hier mal zum Vergleich. Ohne Wertung :)

Edit: Mit VM-Settings..
 
Zuletzt bearbeitet:

Fu3L

Top Contributor
Code:
SYSTEM
	OS: Windows 7 (6.1, )
	Java Version: Java HotSpot(TM) 64-Bit Server VM 1.6.0_23-b05 (Sun Microsystems Inc.)
	Arch: amd64
	CPUs: 8
	MaxMemory (in byte): 952631296
	TotalMemory (in byte): 64225280
	FreeMemory (in byte): 63889720
	UsedMemory (in byte): 335560

	BenchmarkLoop: 20
	ElementLoop: 10000000
	Run GC: 
RUN 1
	Time (ArrayList): 13 ms
	Run GC: 	Time (Integer Array): 2218 ms
	Run GC: 	Time (int Array): 27 ms
	Run GC: 
RUN 2
	Time (ArrayList): 5 ms
	Run GC: 	Time (Integer Array): 689 ms
	Run GC: 	Time (int Array): 20 ms
	Run GC: 
RUN 3
	Time (ArrayList): 5 ms
	Run GC: 	Time (Integer Array): 255 ms
	Run GC: 	Time (int Array): 18 ms
	Run GC: 
RUN 4
	Time (ArrayList): 4 ms
	Run GC: 	Time (Integer Array): 285 ms
	Run GC: 	Time (int Array): 19 ms
	Run GC: 
RUN 5
	Time (ArrayList): 4 ms
	Run GC: 	Time (Integer Array): 260 ms
	Run GC: 	Time (int Array): 20 ms
	Run GC: 
RUN 6
	Time (ArrayList): 5 ms
	Run GC: 	Time (Integer Array): 255 ms
	Run GC: 	Time (int Array): 21 ms
	Run GC: 
RUN 7
	Time (ArrayList): 5 ms
	Run GC: 	Time (Integer Array): 261 ms
	Run GC: 	Time (int Array): 21 ms
	Run GC: 
RUN 8
	Time (ArrayList): 5 ms
	Run GC: 	Time (Integer Array): 270 ms
	Run GC: 	Time (int Array): 21 ms
	Run GC: 
RUN 9
	Time (ArrayList): 7 ms
	Run GC: 	Time (Integer Array): 264 ms
	Run GC: 	Time (int Array): 23 ms
	Run GC: 
RUN 10
	Time (ArrayList): 5 ms
	Run GC: 	Time (Integer Array): 265 ms
	Run GC: 	Time (int Array): 22 ms
	Run GC: 
RUN 11
	Time (ArrayList): 5 ms
	Run GC: 	Time (Integer Array): 267 ms
	Run GC: 	Time (int Array): 22 ms
	Run GC: 
RUN 12
	Time (ArrayList): 5 ms
	Run GC: 	Time (Integer Array): 257 ms
	Run GC: 	Time (int Array): 21 ms
	Run GC: 
RUN 13
	Time (ArrayList): 5 ms
	Run GC: 	Time (Integer Array): 257 ms
	Run GC: 	Time (int Array): 21 ms
	Run GC: 
RUN 14
	Time (ArrayList): 5 ms
	Run GC: 	Time (Integer Array): 258 ms
	Run GC: 	Time (int Array): 21 ms
	Run GC: 
RUN 15
	Time (ArrayList): 5 ms
	Run GC: 	Time (Integer Array): 257 ms
	Run GC: 	Time (int Array): 21 ms
	Run GC: 
RUN 16
	Time (ArrayList): 5 ms
	Run GC: 	Time (Integer Array): 264 ms
	Run GC: 	Time (int Array): 22 ms
	Run GC: 
RUN 17
	Time (ArrayList): 5 ms
	Run GC: 	Time (Integer Array): 262 ms
	Run GC: 	Time (int Array): 23 ms
	Run GC: 
RUN 18
	Time (ArrayList): 5 ms
	Run GC: 	Time (Integer Array): 261 ms
	Run GC: 	Time (int Array): 22 ms
	Run GC: 
RUN 19
	Time (ArrayList): 5 ms
	Run GC: 	Time (Integer Array): 264 ms
	Run GC: 	Time (int Array): 22 ms
	Run GC: 
RUN 20
	Time (ArrayList): 4 ms
	Run GC: 	Time (Integer Array): 254 ms
	Run GC: 	Time (int Array): 21 ms
	Run GC: 
SYSTEM
	OS: Windows 7 (6.1, )
	Java Version: Java HotSpot(TM) 64-Bit Server VM 1.6.0_23-b05 (Sun Microsystems Inc.)
	Arch: amd64
	CPUs: 8
	MaxMemory (in byte): 952631296
	TotalMemory (in byte): 488898560
	FreeMemory (in byte): 486681184
	UsedMemory (in byte): 2217376

	BenchmarkLoop: 20
	ElementLoop: 10000000

END RESULTS
	Average Time (ArrayList): 5 ms
	Average Time (Integer Array): 381 ms
	Average Time (int Array): 21 ms

Code:
SYSTEM
	OS: Windows 7 (6.1, )
	Java Version: Java HotSpot(TM) 64-Bit Server VM 1.6.0_23-b05 (Sun Microsystems Inc.)
	Arch: amd64
	CPUs: 8
	MaxMemory (in byte): 952631296
	TotalMemory (in byte): 64225280
	FreeMemory (in byte): 63889720
	UsedMemory (in byte): 335560

	BenchmarkLoop: 20
	ElementLoop: 10000000
	Run GC: 
RUN 1
	Time (ArrayList): 14 ms
	Run GC: 	Time (Integer Array): 2380 ms
	Run GC: 	Time (int Array): 27 ms
	Run GC: 
RUN 2
	Time (ArrayList): 4 ms
	Run GC: 	Time (Integer Array): 657 ms
	Run GC: 	Time (int Array): 24 ms
	Run GC: 
RUN 3
	Time (ArrayList): 5 ms
	Run GC: 	Time (Integer Array): 270 ms
	Run GC: 	Time (int Array): 20 ms
	Run GC: 
RUN 4
	Time (ArrayList): 4 ms
	Run GC: 	Time (Integer Array): 329 ms
	Run GC: 	Time (int Array): 22 ms
	Run GC: 
RUN 5
	Time (ArrayList): 5 ms
	Run GC: 	Time (Integer Array): 286 ms
	Run GC: 	Time (int Array): 22 ms
	Run GC: 
RUN 6
	Time (ArrayList): 6 ms
	Run GC: 	Time (Integer Array): 289 ms
	Run GC: 	Time (int Array): 26 ms
	Run GC: 
RUN 7
	Time (ArrayList): 5 ms
	Run GC: 	Time (Integer Array): 275 ms
	Run GC: 	Time (int Array): 23 ms
	Run GC: 
RUN 8
	Time (ArrayList): 5 ms
	Run GC: 	Time (Integer Array): 290 ms
	Run GC: 	Time (int Array): 23 ms
	Run GC: 
RUN 9
	Time (ArrayList): 5 ms
	Run GC: 	Time (Integer Array): 291 ms
	Run GC: 	Time (int Array): 22 ms
	Run GC: 
RUN 10
	Time (ArrayList): 5 ms
	Run GC: 	Time (Integer Array): 281 ms
	Run GC: 	Time (int Array): 24 ms
	Run GC: 
RUN 11
	Time (ArrayList): 5 ms
	Run GC: 	Time (Integer Array): 282 ms
	Run GC: 	Time (int Array): 22 ms
	Run GC: 
RUN 12
	Time (ArrayList): 5 ms
	Run GC: 	Time (Integer Array): 288 ms
	Run GC: 	Time (int Array): 24 ms
	Run GC: 
RUN 13
	Time (ArrayList): 5 ms
	Run GC: 	Time (Integer Array): 276 ms
	Run GC: 	Time (int Array): 24 ms
	Run GC: 
RUN 14
	Time (ArrayList): 6 ms
	Run GC: 	Time (Integer Array): 285 ms
	Run GC: 	Time (int Array): 23 ms
	Run GC: 
RUN 15
	Time (ArrayList): 4 ms
	Run GC: 	Time (Integer Array): 288 ms
	Run GC: 	Time (int Array): 22 ms
	Run GC: 
RUN 16
	Time (ArrayList): 5 ms
	Run GC: 	Time (Integer Array): 293 ms
	Run GC: 	Time (int Array): 24 ms
	Run GC: 
RUN 17
	Time (ArrayList): 5 ms
	Run GC: 	Time (Integer Array): 290 ms
	Run GC: 	Time (int Array): 23 ms
	Run GC: 
RUN 18
	Time (ArrayList): 4 ms
	Run GC: 	Time (Integer Array): 314 ms
	Run GC: 	Time (int Array): 27 ms
	Run GC: 
RUN 19
	Time (ArrayList): 4 ms
	Run GC: 	Time (Integer Array): 290 ms
	Run GC: 	Time (int Array): 21 ms
	Run GC: 
RUN 20
	Time (ArrayList): 4 ms
	Run GC: 	Time (Integer Array): 286 ms
	Run GC: 	Time (int Array): 24 ms
	Run GC: 
SYSTEM
	OS: Windows 7 (6.1, )
	Java Version: Java HotSpot(TM) 64-Bit Server VM 1.6.0_23-b05 (Sun Microsystems Inc.)
	Arch: amd64
	CPUs: 8
	MaxMemory (in byte): 952631296
	TotalMemory (in byte): 488046592
	FreeMemory (in byte): 485829216
	UsedMemory (in byte): 2217376

	BenchmarkLoop: 20
	ElementLoop: 10000000

END RESULTS
	Average Time (ArrayList): 5 ms
	Average Time (Integer Array): 412 ms
	Average Time (int Array): 23 ms

Habs in Eclipse ausgeführt. 2 Mal, weil ich mich über die Langsamkeit meines (eigentlich ziemlich schnellen) Prozessors wunderte.... Ich schiebs mal auf die geringe Taktfrequenz eines einzelnen Prozessorkerns^^
 

CroniD

Aktives Mitglied
Habs in Eclipse ausgeführt. 2 Mal, weil ich mich über die Langsamkeit meines (eigentlich ziemlich schnellen) Prozessors wunderte.... Ich schiebs mal auf die geringe Taktfrequenz eines einzelnen Prozessorkerns^^

Danke. :)

Aber du hast die VM Args vergessen anzugeben. In Eclipse kannst du diese in den RunConf. der Klasse IntegerTest hinterlegen. Findet sich auf dem zweiten Tabreiter "(x)= Arguments" und im Feld "VM Arguments:" trägst du "-Xms768m -Xmx768m -verbose:gc" ein. Kannst du diese Ergebnisse dann nochmal hier posten? Das ist wichtig, weil sonst der GC unnötig dazwischen funkt und evtl. die Messung versaut.
 

Fu3L

Top Contributor
Code:
SYSTEM
	OS: Windows 7 (6.1, )
	Java Version: Java HotSpot(TM) 64-Bit Server VM 1.6.0_23-b05 (Sun Microsystems Inc.)
	Arch: amd64
	CPUs: 8
	MaxMemory (in byte): 771751936
	TotalMemory (in byte): 771751936
	FreeMemory (in byte): 767725392
	UsedMemory (in byte): 4026544

	BenchmarkLoop: 20
	ElementLoop: 10000000
	Run GC: [GC 3932K->256K(753664K), 0.0147503 secs]
[Full GC 256K->122K(753664K), 0.0050628 secs]

RUN 1
	Time (ArrayList): 14 ms
	Run GC: [GC 43117K->39281K(753664K), 0.0827839 secs]
[Full GC 39281K->39192K(753664K), 0.0729116 secs]
	Time (Integer Array): 135 ms
	Run GC: [GC 235541K->39320K(753664K), 0.0195039 secs]
[Full GC 39320K->134K(753664K), 0.0048261 secs]
	Time (int Array): 30 ms
	Run GC: [GC 42738K->134K(753664K), 0.0003548 secs]
[Full GC 134K->134K(753664K), 0.0065071 secs]

RUN 2
	Time (ArrayList): 4 ms
	Run GC: [GC 42738K->39229K(753664K), 0.0799961 secs]
[Full GC 39229K->39197K(753664K), 0.0624825 secs]
	Time (Integer Array): 82 ms
	Run GC: [GC 235805K->39197K(753664K), 0.0009682 secs]
[Full GC 39197K->134K(753664K), 0.0053541 secs]
	Time (int Array): 21 ms
	Run GC: [GC 42614K->134K(753664K), 0.0003882 secs]
[Full GC 134K->134K(753664K), 0.0050423 secs]

RUN 3
	Time (ArrayList): 5 ms
	Run GC: [GC 42614K->134K(753664K), 0.0005043 secs]
[Full GC 134K->134K(753664K), 0.0036905 secs]
	Time (Integer Array): 62 ms
	Run GC: [GC 196383K->134K(753664K), 0.0008668 secs]
[Full GC 134K->134K(753664K), 0.0045887 secs]
	Time (int Array): 18 ms
	Run GC: [GC 42520K->134K(753664K), 0.0003529 secs]
[Full GC 134K->134K(753664K), 0.0044167 secs]

RUN 4
	Time (ArrayList): 4 ms
	Run GC: [GC 42520K->134K(753664K), 0.0003234 secs]
[Full GC 134K->134K(753664K), 0.0038817 secs]
	Time (Integer Array): 60 ms
	Run GC: [GC 196742K->134K(753664K), 0.0003298 secs]
[Full GC 134K->134K(753664K), 0.0041306 secs]
	Time (int Array): 21 ms
	Run GC: [GC 42474K->134K(753664K), 0.0005762 secs]
[Full GC 134K->134K(753664K), 0.0039092 secs]

RUN 5
	Time (ArrayList): 5 ms
	Run GC: [GC 42474K->134K(753664K), 0.0002765 secs]
[Full GC 134K->134K(753664K), 0.0033049 secs]
	Time (Integer Array): 66 ms
	Run GC: [GC 196488K->134K(753664K), 0.0003009 secs]
[Full GC 134K->134K(753664K), 0.0049005 secs]
	Time (int Array): 21 ms
	Run GC: [GC 42429K->134K(753664K), 0.0055203 secs]
[Full GC 134K->134K(753664K), 0.0036314 secs]

RUN 6
	Time (ArrayList): 5 ms
	Run GC: [GC 42429K->134K(753664K), 0.0050423 secs]
[Full GC 134K->134K(753664K), 0.0040157 secs]
	Time (Integer Array): 63 ms
	Run GC: [GC 196742K->134K(753664K), 0.0053509 secs]
[Full GC 134K->134K(753664K), 0.0050340 secs]
	Time (int Array): 22 ms
	Run GC: [GC 42407K->134K(753664K), 0.0003631 secs]
[Full GC 134K->134K(753664K), 0.0051020 secs]

RUN 7
	Time (ArrayList): 5 ms
	Run GC: [GC 42407K->134K(753664K), 0.0003137 secs]
[Full GC 134K->134K(753664K), 0.0051616 secs]
	Time (Integer Array): 67 ms
	Run GC: [GC 196478K->134K(753664K), 0.0007962 secs]
[Full GC 134K->134K(753664K), 0.0050776 secs]
	Time (int Array): 21 ms
	Run GC: [GC 42386K->134K(753664K), 0.0002906 secs]
[Full GC 134K->134K(753664K), 0.0036885 secs]

RUN 8
	Time (ArrayList): 5 ms
	Run GC: [GC 42386K->134K(753664K), 0.0008860 secs]
[Full GC 134K->134K(753664K), 0.0032580 secs]
	Time (Integer Array): 61 ms
	Run GC: [GC 195449K->134K(753664K), 0.0004215 secs]
[Full GC 134K->134K(753664K), 0.0043314 secs]
	Time (int Array): 22 ms
	Run GC: [GC 42371K->134K(753664K), 0.0005191 secs]
[Full GC 134K->134K(753664K), 0.0041261 secs]

RUN 9
	Time (ArrayList): 5 ms
	Run GC: [GC 42371K->134K(753664K), 0.0003529 secs]
[Full GC 134K->134K(753664K), 0.0036545 secs]
	Time (Integer Array): 65 ms
	Run GC: [GC 196742K->134K(753664K), 0.0002836 secs]
[Full GC 134K->134K(753664K), 0.0042172 secs]
	Time (int Array): 23 ms
	Run GC: [GC 42371K->134K(753664K), 0.0008745 secs]
[Full GC 134K->134K(753664K), 0.0044726 secs]

RUN 10
	Time (ArrayList): 5 ms
	Run GC: [GC 42371K->134K(753664K), 0.0054151 secs]
[Full GC 134K->134K(753664K), 0.0048556 secs]
	Time (Integer Array): 62 ms
	Run GC: [GC 196742K->134K(753664K), 0.0003298 secs]
[Full GC 134K->134K(753664K), 0.0043102 secs]
	Time (int Array): 20 ms
	Run GC: [GC 42371K->134K(753664K), 0.0004010 secs]
[Full GC 134K->134K(753664K), 0.0045637 secs]

RUN 11
	Time (ArrayList): 5 ms
	Run GC: [GC 42371K->134K(753664K), 0.0003991 secs]
[Full GC 134K->134K(753664K), 0.0038393 secs]
	Time (Integer Array): 57 ms
	Run GC: [GC 196742K->134K(753664K), 0.0046054 secs]
[Full GC 134K->134K(753664K), 0.0042807 secs]
	Time (int Array): 21 ms
	Run GC: [GC 42371K->134K(753664K), 0.0005088 secs]
[Full GC 134K->134K(753664K), 0.0046112 secs]

RUN 12
	Time (ArrayList): 5 ms
	Run GC: [GC 42371K->134K(753664K), 0.0002894 secs]
[Full GC 134K->134K(753664K), 0.0040170 secs]
	Time (Integer Array): 59 ms
	Run GC: [GC 196742K->134K(753664K), 0.0031964 secs]
[Full GC 134K->134K(753664K), 0.0047619 secs]
	Time (int Array): 19 ms
	Run GC: [GC 42371K->134K(753664K), 0.0003375 secs]
[Full GC 134K->134K(753664K), 0.0042775 secs]

RUN 13
	Time (ArrayList): 4 ms
	Run GC: [GC 42371K->134K(753664K), 0.0072969 secs]
[Full GC 134K->134K(753664K), 0.0042057 secs]
	Time (Integer Array): 58 ms
	Run GC: [GC 196742K->134K(753664K), 0.0029045 secs]
[Full GC 134K->134K(753664K), 0.0040376 secs]
	Time (int Array): 21 ms
	Run GC: [GC 42371K->134K(753664K), 0.0003920 secs]
[Full GC 134K->134K(753664K), 0.0043988 secs]

RUN 14
	Time (ArrayList): 5 ms
	Run GC: [GC 42371K->134K(753664K), 0.0003368 secs]
[Full GC 134K->134K(753664K), 0.0038502 secs]
	Time (Integer Array): 64 ms
	Run GC: [GC 196742K->134K(753664K), 0.0010240 secs]
[Full GC 134K->134K(753664K), 0.0039792 secs]
	Time (int Array): 20 ms
	Run GC: [GC 42371K->134K(753664K), 0.0004478 secs]
[Full GC 134K->134K(753664K), 0.0037110 secs]

RUN 15
	Time (ArrayList): 5 ms
	Run GC: [GC 42371K->134K(753664K), 0.0003535 secs]
[Full GC 134K->134K(753664K), 0.0034396 secs]
	Time (Integer Array): 64 ms
	Run GC: [GC 196742K->134K(753664K), 0.0008790 secs]
[Full GC 134K->134K(753664K), 0.0036930 secs]
	Time (int Array): 21 ms
	Run GC: [GC 42371K->134K(753664K), 0.0003490 secs]
[Full GC 134K->134K(753664K), 0.0042878 secs]

RUN 16
	Time (ArrayList): 6 ms
	Run GC: [GC 42371K->134K(753664K), 0.0051424 secs]
[Full GC 134K->134K(753664K), 0.0039432 secs]
	Time (Integer Array): 59 ms
	Run GC: [GC 196742K->134K(753664K), 0.0007924 secs]
[Full GC 134K->134K(753664K), 0.0040812 secs]
	Time (int Array): 21 ms
	Run GC: [GC 42371K->134K(753664K), 0.0003869 secs]
[Full GC 134K->134K(753664K), 0.0043109 secs]

RUN 17
	Time (ArrayList): 5 ms
	Run GC: [GC 42371K->134K(753664K), 0.0003227 secs]
[Full GC 134K->134K(753664K), 0.0038528 secs]
	Time (Integer Array): 63 ms
	Run GC: [GC 196742K->134K(753664K), 0.0006942 secs]
[Full GC 134K->134K(753664K), 0.0040125 secs]
	Time (int Array): 22 ms
	Run GC: [GC 42371K->134K(753664K), 0.0003503 secs]
[Full GC 134K->134K(753664K), 0.0035814 secs]

RUN 18
	Time (ArrayList): 5 ms
	Run GC: [GC 42371K->134K(753664K), 0.0004446 secs]
[Full GC 134K->134K(753664K), 0.0041986 secs]
	Time (Integer Array): 62 ms
	Run GC: [GC 196742K->134K(753664K), 0.0008405 secs]
[Full GC 134K->134K(753664K), 0.0045521 secs]
	Time (int Array): 19 ms
	Run GC: [GC 42371K->134K(753664K), 0.0003907 secs]
[Full GC 134K->134K(753664K), 0.0041524 secs]

RUN 19
	Time (ArrayList): 5 ms
	Run GC: [GC 42371K->134K(753664K), 0.0107121 secs]
[Full GC 134K->134K(753664K), 0.0038361 secs]
	Time (Integer Array): 65 ms
	Run GC: [GC 196742K->134K(753664K), 0.0008989 secs]
[Full GC 134K->134K(753664K), 0.0044681 secs]
	Time (int Array): 21 ms
	Run GC: [GC 42371K->134K(753664K), 0.0004536 secs]
[Full GC 134K->134K(753664K), 0.0042936 secs]

RUN 20
	Time (ArrayList): 5 ms
	Run GC: [GC 42371K->134K(753664K), 0.0042673 secs]
[Full GC 134K->134K(753664K), 0.0042204 secs]
	Time (Integer Array): 62 ms
	Run GC: [GC 196742K->134K(753664K), 0.0043231 secs]
[Full GC 134K->134K(753664K), 0.0041678 secs]
	Time (int Array): 19 ms
	Run GC: [GC 42371K->134K(753664K), 0.0002913 secs]
[Full GC 134K->134K(753664K), 0.0042153 secs]

SYSTEM
	OS: Windows 7 (6.1, )
	Java Version: Java HotSpot(TM) 64-Bit Server VM 1.6.0_23-b05 (Sun Microsystems Inc.)
	Arch: amd64
	CPUs: 8
	MaxMemory (in byte): 771751936
	TotalMemory (in byte): 771751936
	FreeMemory (in byte): 768363688
	UsedMemory (in byte): 3388248

	BenchmarkLoop: 20
	ElementLoop: 10000000

END RESULTS
	Average Time (ArrayList): 5 ms
	Average Time (Integer Array): 66 ms
	Average Time (int Array): 21 ms

Mein Prozessor ist doch nicht so lahm^^ :D

Edit: Bin dafür aber überrascht, wie viel Rechenzeit der gc beansprucht^^
 

Lumaraf

Bekanntes Mitglied
Die Zeiten für ArrayList sind falsch. Das erste Argument für new ArrayList<?>(initialCapacity); legt nur die Größe des zur Speicherung der Einträge nötigen internen Arrays fest. Die Methode size() liefert in dem Benchmark daher immer 0 was dazu führt das bei dem ArrayList-Test die Schleife komplett übersprugen wird. Wenn der Bug behoben ist schneidet das int[] auch mit Abstand am besten ab.
 

Marco13

Top Contributor
Ob das GC da irgendeinen Sinn macht ... der GC läuft ohnehin, wann er will. Bei mir sind's (wenn der Fehler koorigiert ist) mit -server und -Xmx1200m
Code:
SYSTEM
	OS: Windows XP (5.1, Service Pack 3)
	Java Version: Java HotSpot(TM) Server VM 1.6.0_10-b33 (Sun Microsystems Inc.)
	Arch: x86
	CPUs: 4
	MaxMemory (in byte): 517013504
	TotalMemory (in byte): 33554432
	FreeMemory (in byte): 33332728
	UsedMemory (in byte): 221704

	BenchmarkLoop: 20
	ElementLoop: 10000000
	Run GC: 
RUN 1
	Time (ArrayList): 2844 ms
	Run GC: 	Time (Integer Array): 2250 ms
	Run GC: 	Time (int Array): 31 ms
	Run GC: 
RUN 2
	Time (ArrayList): 2062 ms
	Run GC: 	Time (Integer Array): 2016 ms
	Run GC: 	Time (int Array): 31 ms
	Run GC: 
...
(danach ändert sich praktisch nichts mehr)
 
Ähnliche Java Themen
  Titel Forum Antworten Datum
S Intressante Benchmark-Ergebnisse mit Listen. Weiss jemand wie man diese erklaeren kann? Allgemeine Java-Themen 15
X Lotto - google caliper Benchmark Allgemeine Java-Themen 4
Antoras Micro-benchmark für parallel vs. sequentiell erzeugt unerwartetes Ergebnis Allgemeine Java-Themen 8
P Micro- Benchmark Allgemeine Java-Themen 5
G Mysteriöser Benchmark: For-Loop Allgemeine Java-Themen 14
MCDragon IDEA IntelliJ Integer Number Too Long - Help Allgemeine Java-Themen 1
mrStudent The method append is not applicable for the arguments (Queue<Integer>, Queue<Integer>) Allgemeine Java-Themen 4
O JSON in Integer parsen Allgemeine Java-Themen 5
D Kgv aller Paare aus einem Array mit n integer berechnen Allgemeine Java-Themen 5
D Integer-Array variabler Größe mit Zahlen befüllen (Schleifen) Allgemeine Java-Themen 0
J Mit Lombok Integer Range prüfen Allgemeine Java-Themen 6
L Variablen Eigenes Objekt wie z.B. einen Integer zuweisen Allgemeine Java-Themen 3
R Datentypen Korrekte integer in Hex ASCII Konvertierung und serialisierung Allgemeine Java-Themen 1
B List<Integer> ist List<Double> ? Allgemeine Java-Themen 6
E String in Zahl umwandeln, ohne Befehl Integer.parseInt Allgemeine Java-Themen 3
J Eine bestimmte Zahl im Integer ändern Allgemeine Java-Themen 9
V Eingegeben String Splitten und in Integer umwandeln Allgemeine Java-Themen 2
J Transfer von Integer zwischen zwei Clients - RMI Allgemeine Java-Themen 4
heyluigi Random Integer Array Ausgabe nach Größe sortieren Allgemeine Java-Themen 6
X Integer.numberOfTrailingZeros() Allgemeine Java-Themen 1
K Array, Int expected, Integer found Allgemeine Java-Themen 5
HarleyDavidson Best Practice Integer-Zahlenfolge über mehrere Programmstarts Allgemeine Java-Themen 7
B Transferable in String/Integer umwandeln Allgemeine Java-Themen 11
K Input/Output Integer.parseInt() an Textdateien anwenden Allgemeine Java-Themen 2
D Beste Collection für Integer Allgemeine Java-Themen 4
Zettelkasten Double --> Integer Allgemeine Java-Themen 4
M Datentypen ArrayList in Integer konvertieren Allgemeine Java-Themen 3
S Variablen Prüfen ob Number vom Typ Integer, Float, Double, ... ist Allgemeine Java-Themen 2
O Input/Output Textfeld: nur Integer annehmen Allgemeine Java-Themen 9
T int <-> integer, double <-> Double... Allgemeine Java-Themen 2
P JFormattedTextField für durch Semikolon getrennte Integer-Werte gesucht / Regulärer Ausdruck Allgemeine Java-Themen 3
GianaSisters Klassen ArrayList Index Integer int Allgemeine Java-Themen 5
G Datentypen JGoodies Binding und JSpinner mit Integer Allgemeine Java-Themen 2
L Problem mit Integer.parseInt Allgemeine Java-Themen 17
Rudolf Aus Collection<Integer> eine Zahl machen Allgemeine Java-Themen 2
O Nach parse von String zu Integer verliere ich Programmablauf! Allgemeine Java-Themen 10
Z Cast von Long zu Integer funktionert nicht Allgemeine Java-Themen 3
E Zweidimensionales Array Integer[10 000][10 000] -> out of memory? Allgemeine Java-Themen 4
T Integer aus InputStream lesen Allgemeine Java-Themen 3
S String[] in Integer umwandeln Allgemeine Java-Themen 16
K Heap-Volllaufen bei ArrayList<Integer> Allgemeine Java-Themen 9
C Character in Integer Allgemeine Java-Themen 12
D Double to Integer - ist das möglich? Allgemeine Java-Themen 3
R Anführungszeichen Integer.valueOf(String).intValue(); Allgemeine Java-Themen 6
H Integer/String Allgemeine Java-Themen 9
MQue byte[] Array to Integer Allgemeine Java-Themen 4
J Mit mehrdimensionalen Integer-Arrays arbeiten Allgemeine Java-Themen 17
R Eigene ArrayList vom Typ Short, Integer oder Double Allgemeine Java-Themen 4
G erzeugen von "ArrayList<Integer>[][]" Allgemeine Java-Themen 7
M Integer.parseInt Allgemeine Java-Themen 4
G enum Integer zuweisen Allgemeine Java-Themen 14
G Integer aus String Allgemeine Java-Themen 4
X cannot convert from Object[] to Integer[] Allgemeine Java-Themen 2
B 16Bit Integer aus ByteArray im Little Endian Format Allgemeine Java-Themen 17
O java.lang.NumberFormatException für normalen integer Allgemeine Java-Themen 4
T Integer hhmm addieren Allgemeine Java-Themen 11
MQue Integer in String Allgemeine Java-Themen 2
G Datumswert String in Integer umwandeln Allgemeine Java-Themen 2
P Integer und Bit-operationen Allgemeine Java-Themen 21
M Java 1.4 und Integer Allgemeine Java-Themen 3
G ArrayList<String> to ArrayList<Integer Allgemeine Java-Themen 2
S Integer zu int konvertieren - JUnit Allgemeine Java-Themen 12
J Integer Array Wert vorhanden? Allgemeine Java-Themen 6
M String nach Integer und führende Nullen Allgemeine Java-Themen 6
B Plaintext Integer einlesen und verarbeiten Allgemeine Java-Themen 3
R cast Integer[] zu int[] Allgemeine Java-Themen 2
D byte nach integer? Allgemeine Java-Themen 4
MQue Object in Integer umwandeln Allgemeine Java-Themen 3
H Integer#valueOf(int) bei 1.4 Allgemeine Java-Themen 7
M Datenstrukrue, List<Map<Integer, Map<String, . Allgemeine Java-Themen 2
M Integer in String umwandeln Allgemeine Java-Themen 7
S Object nach Integer umwandeln Allgemeine Java-Themen 13
R Integer will sich nicht lesen lassen! Allgemeine Java-Themen 9
G Umwandlung Byte in Integer Allgemeine Java-Themen 12
M reflection Integer != int ? Allgemeine Java-Themen 3
P int != Integer Allgemeine Java-Themen 3
N Prüfen ob ein String in einen Integer umgewandelt werden kan Allgemeine Java-Themen 4
P Class zu Integer, String, Double etc. Allgemeine Java-Themen 11
S Integer-Zahlen in Excel-Sheet schreiben Allgemeine Java-Themen 10
T JNI: jcharArray: warning: cast to pointer from integer of. Allgemeine Java-Themen 5
R Float richtig in Integer ? Allgemeine Java-Themen 4
T Integer und TextFelder Allgemeine Java-Themen 3
S Integer-splitten für Abfrage. Allgemeine Java-Themen 4
M Index eines Arrays ermitteln und als Integer ausgeben Allgemeine Java-Themen 7
B Integer zählen bzw. speichern Allgemeine Java-Themen 3
H Array nimmt keinen in Integer konvertierten String auf! Allgemeine Java-Themen 26
H Prüfen, ob es sich um ein Integer handelt Allgemeine Java-Themen 4
J Integer.parseInt funktioniert nicht immer Allgemeine Java-Themen 3
G Nur Integer Werte in JTextField Allgemeine Java-Themen 4
V Typumwandlung Integer, Float etc in String Allgemeine Java-Themen 4
C String in Integer wandeln Allgemeine Java-Themen 17

Ähnliche Java Themen


Oben