~ubuntu-branches/ubuntu/raring/libjboss-remoting-java/raring

« back to all changes in this revision

Viewing changes to src/tests/org/jboss/test/remoting/performance/profiler/ProfileTest2.java

  • Committer: Package Import Robot
  • Author(s): Torsten Werner
  • Date: 2011-09-09 14:01:03 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: package-import@ubuntu.com-20110909140103-hqokx61534tas9rg
Tags: 2.5.3.SP1-1
* Newer but not newest upstream release. Do not build samples.
* Change debian/watch to upstream's svn repo.
* Add patch to fix compile error caused by tomcat update.
  (Closes: #628303)
* Switch to source format 3.0.
* Switch to debhelper level 7.
* Remove useless Depends.
* Update Standards-Version: 3.9.2.
* Update README.source.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package org.jboss.test.remoting.performance.profiler;
 
2
 
 
3
import org.jboss.test.remoting.performance.synchronous.PerformanceClientTest;
 
4
import org.jboss.test.remoting.performance.synchronous.PerformanceServerTest;
 
5
import org.jboss.test.remoting.performance.synchronous.PerformanceTestCase;
 
6
 
 
7
/**
 
8
 * @author <a href="mailto:tom.elrod@jboss.com">Tom Elrod</a>
 
9
 */
 
10
public class ProfileTest2
 
11
{
 
12
   private static int numOfClients = 10;
 
13
   private static int numOfLoops = 100;
 
14
 
 
15
   private String numOfCalls = "1000";
 
16
//   private String numOfCalls = "1000000";
 
17
 
 
18
   private PerformanceServerTest server = null;
 
19
 
 
20
 
 
21
   public void profilerTest() throws Throwable
 
22
   {
 
23
      setupServer();
 
24
 
 
25
      System.setProperty(PerformanceTestCase.NUMBER_OF_CALLS, numOfCalls);
 
26
      System.setProperty(PerformanceTestCase.REMOTING_METADATA, "foo=bar");
 
27
 
 
28
      for(int x = 0; x < numOfClients; x++)
 
29
      {
 
30
         new Thread(new Runnable()
 
31
         {
 
32
            public void run()
 
33
            {
 
34
               try
 
35
               {
 
36
                  for(int i = 0; i < numOfLoops;i++)
 
37
                  {
 
38
                     runClientTest();
 
39
                  }
 
40
               }
 
41
               catch(Throwable throwable)
 
42
               {
 
43
                  throwable.printStackTrace();
 
44
               }
 
45
            }
 
46
         }).start();
 
47
      }
 
48
 
 
49
      while(numOfClients > 0)
 
50
      {
 
51
         Thread.currentThread().sleep(5000);
 
52
      }
 
53
 
 
54
      server.tearDown();
 
55
 
 
56
   }
 
57
 
 
58
 
 
59
   public void setupServer() throws Exception
 
60
   {
 
61
      server = new PerformanceServerTest();
 
62
      server.setUp();
 
63
      System.out.println("Server setup");
 
64
   }
 
65
 
 
66
 
 
67
   public void runClientTest() throws Throwable
 
68
   {
 
69
 
 
70
      PerformanceClientTest client = new PerformanceClientTest();
 
71
      client.setUp();
 
72
      System.out.println("Client setup");
 
73
 
 
74
      client.testClientCalls();
 
75
      System.out.println("Done with testing client calls");
 
76
 
 
77
 
 
78
      client.tearDown();
 
79
 
 
80
      numOfClients--;
 
81
 
 
82
      System.out.println("Number of clients = " + numOfClients);
 
83
   }
 
84
 
 
85
   public static void main(String[] args)
 
86
   {
 
87
      ProfileTest2 test = new ProfileTest2();
 
88
      try
 
89
      {
 
90
         test.profilerTest();
 
91
      }
 
92
      catch(Throwable throwable)
 
93
      {
 
94
         throwable.printStackTrace();
 
95
      }
 
96
   }
 
97
}