View Javadoc

1   /*
2    * Copyright 2010 Fraunhofer Gesellschaft, Munich, Germany,
3    * for its Fraunhofer Institute for Computer Architecture and Software
4    * Technology (FIRST), Berlin, Germany. All rights reserved.
5    * http://www.first.fraunhofer.de/
6    */
7   
8   package net.kwfgrid.gwes;
9   
10  import net.kwfgrid.gwes.exception.*;
11  import org.apache.log4j.Logger;
12  import org.apache.log4j.Level;
13  import org.jaxen.JaxenException;
14  import org.jdom.JDOMException;
15  import junit.framework.Test;
16  import junit.framework.TestSuite;
17  
18  import java.io.IOException;
19  
20  import net.kwfgrid.gworkflowdl.structure.WorkflowFormatException;
21  
22  /**
23   * <code>
24   * maven -Dtestcase=net.kwfgrid.gwes.GWESPerformanceTest test:single
25   * </code>
26   *
27   * @author Andreas Hoheisel
28   *         (<a href="http://www.andreas-hoheisel.de">www.andreas-hoheisel.de</a>)
29   * @version $Id: GWESPerformanceTest.java 1529 2011-06-22 16:37:19Z hoheisel $
30   */
31  public final class GWESPerformanceTest extends LocalGWESAbstractTestCase {
32  
33      static Logger logger = Logger.getLogger(GWESPerformanceTest.class);
34      private Level oldRootLoggerLevel;
35      private Level oldGwesLoggerLevel;
36  
37      private long before;
38      private long after;
39  
40      /**
41       * Create the test case.
42       *
43       * @param testName name of the test case
44       */
45      public GWESPerformanceTest(String testName) throws LoggingException {
46          super(testName);
47      }
48  
49      /**
50       * @return the suite of tests being tested
51       */
52      public static Test suite() {
53          return new TestSuite(GWESPerformanceTest.class);
54      }
55  
56      /**
57       * *******************************************************************************************
58       * Begin of public test classes.
59       * ********************************************************************************************
60       */
61  
62      public void testLoop1() throws IOException, WorkflowFormatException, WorkflowSecurityException, NoSuchWorkflowException, DatabaseException, StateTransitionException, InterruptedException, JaxenException, JDOMException, LoggingException {
63          loggerQuiet();
64          // heat up
65          testGWES("examples/controlflow/control-loop-1.gwdl", WorkflowStatus.STATUS_COMPLETED);
66          before();
67          // real test
68          testGWES("examples/controlflow/control-loop-1.gwdl", WorkflowStatus.STATUS_COMPLETED);
69          after();
70          loggerAsBefore();
71          log("(26.02.2010: 95ms)");
72      }
73  
74      public void testLoop10() throws IOException, WorkflowFormatException, WorkflowSecurityException, NoSuchWorkflowException, DatabaseException, StateTransitionException, InterruptedException, JaxenException, JDOMException, LoggingException {
75          loggerQuiet();
76          before();
77          testGWES("examples/controlflow/control-loop-10.gwdl", WorkflowStatus.STATUS_COMPLETED);
78          after();
79          loggerAsBefore();
80          log("(26.02.2010: 90ms)");
81      }
82  
83      public void testLoop100() throws IOException, WorkflowFormatException, WorkflowSecurityException, NoSuchWorkflowException, DatabaseException, StateTransitionException, InterruptedException, JaxenException, JDOMException, LoggingException {
84          loggerQuiet();
85          before();
86          testGWES("examples/controlflow/control-loop-100.gwdl", WorkflowStatus.STATUS_COMPLETED);
87          after();
88          loggerAsBefore();
89          log("(26.02.2010: 320ms)");
90      }
91  
92      public void testLoop1000() throws IOException, WorkflowFormatException, WorkflowSecurityException, NoSuchWorkflowException, DatabaseException, StateTransitionException, InterruptedException, JaxenException, JDOMException, LoggingException {
93          loggerQuiet();
94          before();
95          testGWES("examples/controlflow/control-loop-1000.gwdl", WorkflowStatus.STATUS_COMPLETED);
96          after();
97          loggerAsBefore();
98          log("(26.02.2010: 900ms)");
99      }
100 
101     public void testLoop10000() throws IOException, WorkflowFormatException, WorkflowSecurityException, NoSuchWorkflowException, DatabaseException, StateTransitionException, InterruptedException, JaxenException, JDOMException, LoggingException {
102         loggerQuiet();
103         before();
104         testGWES("examples/controlflow/control-loop-10000.gwdl", WorkflowStatus.STATUS_COMPLETED);
105         after();
106         loggerAsBefore();
107         log("(26.02.2010: 3270ms)");
108     }
109 
110 //    public void testLoop100000() throws IOException, WorkflowFormatException, NoSuchWorkflowException, DatabaseException, StateTransitionException, InterruptedException, JaxenException, JDOMException {
111 //        loggerQuiet();
112 //        before();
113 //        testGWES("examples/controlflow/control-loop-100000.gwdl", GenericWorkflowHandler.STATUS_COMPLETED);
114 //        after();
115 //        loggerAsBefore();
116 //        log("(26.02.2010: 35300ms)");
117 //    }
118 
119     private void before() {
120         before = System.currentTimeMillis();
121     }
122 
123     private void after() {
124         after = System.currentTimeMillis();
125     }
126 
127     private void log(String message) {
128         logger.info("duration = "+(after-before)+ "ms "+message);
129     }
130 
131     private void loggerQuiet() {
132         // switch off logging
133         Logger rootlogger = Logger.getRootLogger();
134         oldRootLoggerLevel = rootlogger.getLevel();
135         rootlogger.setLevel(Level.ERROR);
136         Logger gweslogger = Logger.getLogger("net.kwfgrid.gwes");
137         oldGwesLoggerLevel = gweslogger.getLevel();
138         gweslogger.setLevel(Level.ERROR);
139     }
140 
141     private void loggerAsBefore() {
142         // switch on logging
143         Logger.getRootLogger().setLevel(oldRootLoggerLevel);
144         Logger.getLogger("net.kwfgrid.gwes").setLevel(oldGwesLoggerLevel);
145     }
146 
147 
148     /**
149      * *******************************************************************************************
150      * End of public test classes.
151      * ********************************************************************************************
152      */
153 
154 }