1414// Copyright (c) 2007-2011 VMware, Inc. All rights reserved.
1515//
1616
17-
1817package com .rabbitmq .examples ;
1918
2019import com .rabbitmq .client .*;
@@ -32,27 +31,27 @@ static Connection connect() throws Exception{
3231
3332 abstract static class PerformanceTest {
3433 String name ;
35- Connection c ;
34+ Connection c ;
3635 int i ;
3736
3837 PerformanceTest (String name ){
3938 this .name = name ;
4039 }
41-
40+
4241 void run () throws Exception {
4342 System .out .println (name );
4443 for (i = START ; i <= CHANNEL_MAX ; i += STEP ){
4544 c = connect ();
46- long start = System .currentTimeMillis ();
47- body ();
45+ long start = System .currentTimeMillis ();
46+ body ();
4847 long time = System .currentTimeMillis () - start ;
4948 System .out .println (i + "\t " + time + " (" + (1000 * i / ((double )time )) + " channels/s)" );
5049 c .close ();
5150 }
52- }
51+ }
5352
5453 abstract void body () throws Exception ;
55-
54+
5655 }
5756
5857 public static void main (String [] args ) throws Exception {
@@ -62,22 +61,22 @@ void body() throws Exception{
6261 c .createChannel ();
6362 }
6463 }
65- }.run ();
64+ }.run ();
6665
6766 new PerformanceTest ("Sequential creation followed by close:" ){
6867 void body () throws Exception {
6968 for (int j = 1 ; j <= i ; j ++){
7069 c .createChannel ().close ();
7170 }
7271 }
73- }.run ();
72+ }.run ();
7473
7574 new PerformanceTest ("Sequential creation then bulk close:" ){
7675 void body () throws Exception {
7776 ArrayList <Channel > channels = new ArrayList <Channel >();
7877 for (int j = 1 ; j <= i ; j ++){
7978 channels .add (c .createChannel ());
80- }
79+ }
8180 for (Channel chan : channels ) chan .close ();
8281 }
8382 }.run ();
@@ -87,7 +86,7 @@ void body() throws Exception{
8786 ArrayList <Channel > channels = new ArrayList <Channel >();
8887 for (int j = 1 ; j <= i ; j ++){
8988 channels .add (c .createChannel ());
90- }
89+ }
9190 Collections .shuffle (channels );
9291 for (Channel chan : channels ) chan .close ();
9392 }
0 commit comments