1   /*
2   * E-nspire Gemini.
3   * A Java and AspectJ based framework that enables transparent 
4   * bidirectional relationships between Plain Old Java Objects.
5   * 
6   * Copyright (C) 2005 Dragan Djuric
7   * 
8   * This program is free software; you can redistribute it and/or
9   * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  * 
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  * 
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21  * 
22  * Contact the author at dragand@dev.java.net
23  */
24  package com.enspire.gemini.performance.test.simple;
25  
26  import com.enspire.gemini.performance.model.simple.A;
27  import com.enspire.gemini.performance.model.simple.ABidirectional;
28  import com.enspire.gemini.performance.model.simple.AUnidirectional;
29  
30  /***
31   * @author Dragan Djuric <dragand@dev.java.net>
32   *
33   */
34  public class PerformanceApp {
35  
36      public static void main(String args[]) {
37          long time = System.currentTimeMillis();
38          for (int i = 0; i < 1000000; i++) {
39              A a1 = new AUnidirectional();
40              A a2 = new AUnidirectional();
41              a1.setA(a2);
42          }
43          long time1 = System.currentTimeMillis();
44          long duration1 = time1 - time;
45          System.out.println("Unidirectional execution time:" + (duration1));
46          A bidirectional1 = new ABidirectional();
47          A unidirectional1 = new AUnidirectional();
48          bidirectional1.setA(unidirectional1);
49          time1 = System.currentTimeMillis();
50          for (int i = 0; i < 10000; i++) {
51              A bidirectional = new ABidirectional();
52              A unidirectional = new AUnidirectional();
53              bidirectional.setA(unidirectional);
54          }
55          long time2 = System.currentTimeMillis();
56          long duration2 = time2 - time1;
57          System.out.println("Bidirectional execution time:" + (duration2));
58      }
59  }