You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jmeter-dev@jakarta.apache.org by se...@apache.org on 2005/11/19 20:05:45 UTC

svn commit: r345673 - /jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/util/SlowSocket.java

Author: sebb
Date: Sat Nov 19 11:05:34 2005
New Revision: 345673

URL: http://svn.apache.org/viewcvs?rev=345673&view=rev
Log:
Tidy up a bit

Modified:
    jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/util/SlowSocket.java

Modified: jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/util/SlowSocket.java
URL: http://svn.apache.org/viewcvs/jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/util/SlowSocket.java?rev=345673&r1=345672&r2=345673&view=diff
==============================================================================
--- jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/util/SlowSocket.java (original)
+++ jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/util/SlowSocket.java Sat Nov 19 11:05:34 2005
@@ -72,12 +72,12 @@
 
     // Override so we can intercept the stream
     public OutputStream getOutputStream() throws IOException {
-        return new SlowOutputStream(super.getOutputStream(),CPS);
+        return new SlowOutputStream(super.getOutputStream());
     }
     
     // Override so we can intercept the stream
     public InputStream getInputStream() throws IOException {
-        return new SlowInputStream(super.getInputStream(),CPS);
+        return new SlowInputStream(super.getInputStream());
     }
 
     // Conversions for milli and nano seconds
@@ -85,9 +85,9 @@
     private static final int NS_PER_SEC = 1000000000;
     private static final int NS_PER_MS  = NS_PER_SEC/MS_PER_SEC;
     
-    private static void pause(int bytes, int cps){
-    	long sleepMS = (bytes*MS_PER_SEC)/cps;
-    	int  sleepNS = (int)(((bytes*MS_PER_SEC)/cps) % NS_PER_MS);
+    private void pause(int bytes){
+    	long sleepMS = (bytes*MS_PER_SEC)/CPS;
+    	int  sleepNS = ((bytes*MS_PER_SEC)/CPS) % NS_PER_MS;
         try {
             Thread.sleep(sleepMS,sleepNS);
         } catch (InterruptedException ignored) {
@@ -96,20 +96,17 @@
     
     private class SlowInputStream extends FilterInputStream {
 
-    	private final int CPS;
-    	
-        public SlowInputStream(InputStream in, int cps) {
+        public SlowInputStream(InputStream in) {
             super(in);
-            CPS=cps;
         }
 
         public int read() throws IOException {
-            pause(1,CPS);
+            pause(1);
             return in.read();
         }
 
         public int read(byte[] b, int off, int len) throws IOException {
-            pause(len,CPS);
+            pause(len);
             return in.read(b, off, len);
         }
 
@@ -117,20 +114,17 @@
     
     private class SlowOutputStream extends FilterOutputStream {
 
-    	private final int CPS;
-    	
-        public SlowOutputStream(OutputStream out, int cps) {
+        public SlowOutputStream(OutputStream out) {
             super(out);
-            CPS=cps;
         }
 
         public void write(byte[] b, int off, int len) throws IOException {
-            pause(len,CPS);
+            pause(len);
             out.write(b, off, len);
         }
 
         public void write(int b) throws IOException {
-            pause(1,CPS);
+            pause(1);
             out.write(b);
         }
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org