--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+package org.simantics.db.tests.performance.java;
+
+import org.simantics.db.testing.base.TestCommonPerf;
+
+/**
+ *
+ */
+public class FieldAccessTest extends TestCommonPerf {
+
+ final static class A {
+
+ final private int value;
+
+ public A(int value) {
+ this.value = value;
+ }
+
+ public int getValue() {
+ return value;
+ }
+
+ }
+
+ final static class B {
+
+ final private int value;
+
+ public B(int value) {
+ this.value = value;
+ }
+
+ }
+
+ public static int LEN1 = 10000;
+ public static int LEN2 = 1000000000;
+
+ public void test() throws Exception {
+
+
+ A a = new A(1);
+ B b = new B(1);
+
+ int counter = 0;
+ long start = System.nanoTime();
+ for(int i=0;i<LEN1;i++) counter += a.getValue();
+ long duration = System.nanoTime() - start;
+
+ int counter2 = 0;
+ long start2 = System.nanoTime();
+ for(int i=0;i<LEN1;i++) counter2 += b.value;
+ long duration2 = System.nanoTime() - start2;
+
+ int counter3 = 0;
+ long start3 = System.nanoTime();
+ for(int i=0;i<LEN2;i++) counter3 += a.getValue();
+ long duration3 = System.nanoTime() - start3;
+
+ int counter4 = 0;
+ long start4 = System.nanoTime();
+ for(int i=0;i<LEN2;i++) counter4 += b.value;
+ long duration4 = System.nanoTime() - start4;
+
+ System.out.println("Finished in " + 1e-9*duration + "s.");
+ System.out.println("Finished in " + 1e-9*duration2 + "s.");
+ System.out.println("Finished in " + 1e-9*duration3 + "s.");
+ System.out.println("Finished in " + 1e-9*duration4 + "s.");
+
+ }
+
+}