1
2
3
4
5
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
24
25
26
27
28
29
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
42
43
44
45 public GWESPerformanceTest(String testName) throws LoggingException {
46 super(testName);
47 }
48
49
50
51
52 public static Test suite() {
53 return new TestSuite(GWESPerformanceTest.class);
54 }
55
56
57
58
59
60
61
62 public void testLoop1() throws IOException, WorkflowFormatException, WorkflowSecurityException, NoSuchWorkflowException, DatabaseException, StateTransitionException, InterruptedException, JaxenException, JDOMException, LoggingException {
63 loggerQuiet();
64
65 testGWES("examples/controlflow/control-loop-1.gwdl", WorkflowStatus.STATUS_COMPLETED);
66 before();
67
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
111
112
113
114
115
116
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
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
143 Logger.getRootLogger().setLevel(oldRootLoggerLevel);
144 Logger.getLogger("net.kwfgrid.gwes").setLevel(oldGwesLoggerLevel);
145 }
146
147
148
149
150
151
152
153
154 }