Skip to Content.
Sympa Menu

ndt-dev - [ndt-dev] [ndt] r1012 committed - Download/upload speed in flash client is now being updated during test...

Subject: NDT-DEV email list created

List archive

[ndt-dev] [ndt] r1012 committed - Download/upload speed in flash client is now being updated during test...


Chronological Thread 
  • From:
  • To:
  • Subject: [ndt-dev] [ndt] r1012 committed - Download/upload speed in flash client is now being updated during test...
  • Date: Wed, 12 Mar 2014 12:17:48 +0000

Revision: 1012
Author:

Date: Wed Mar 12 12:17:39 2014 UTC
Log: Download/upload speed in flash client is now being updated during test duration

http://code.google.com/p/ndt/source/detail?r=1012

Modified:
/branches/Issue131/flash-client/src/TestC2S.as
/branches/Issue131/flash-client/src/TestS2C.as

=======================================
--- /branches/Issue131/flash-client/src/TestC2S.as Fri Feb 21 07:41:20 2014 UTC
+++ /branches/Issue131/flash-client/src/TestC2S.as Wed Mar 12 12:17:39 2014 UTC
@@ -30,6 +30,8 @@
* This class performs the Client-to-Server throughput test.
*/
public class TestC2S {
+ private const SPEED_UPDATE_TIMER:int = 1000; // ms
+
// Valid values for _testStage.
private static const PREPARE_TEST1:int = 0;
private static const PREPARE_TEST2:int = 1;
@@ -45,12 +47,14 @@
private var _c2sTestSuccess:Boolean;
// Time to send data to server on the C2S socket.
private var _c2sTestDuration:Number;
+ private var _c2sTestStartTime:Number;
private var _ctlSocket:Socket;
private var _c2sSocket:Socket;
private var _c2sSendCount:int;
// Bytes not sent from last send operation on the C2S socket.
private var _c2sBytesNotSent:int;
private var _c2sTimer:Timer;
+ private var _speedUpdateTimer:Timer;
private var _dataToSend:ByteArray;
private var _msg:Message;
private var _serverHostname:String;
@@ -64,6 +68,7 @@

_c2sTestSuccess = true; // Initially the test has not failed.
_c2sTestDuration = 0;
+ _c2sTestStartTime = 0;
_dataToSend = new ByteArray();
_c2sSendCount = 0;
_c2sBytesNotSent = 0;
@@ -175,6 +180,8 @@

_c2sTimer = new Timer(NDTConstants.C2S_DURATION);
_c2sTimer.addEventListener(TimerEvent.TIMER, onC2STimeout);
+ _speedUpdateTimer = new Timer(SPEED_UPDATE_TIMER);
+ _speedUpdateTimer.addEventListener(TimerEvent.TIMER, onSpeedUpdate);
_msg = new Message();
_testStage = START_TEST;
TestResults.appendDebugMsg("C2S test: START_TEST stage.");
@@ -244,6 +251,16 @@
TestResults.appendDebugMsg("Timeout for sending data on C2S socket.");
closeC2SSocket();
}
+
+ private function onSpeedUpdate(e:TimerEvent):void {
+ _c2sTestDuration = getTimer() - _c2sTestStartTime;
+ _c2sBytesNotSent = _c2sSocket.bytesPending;
+ var c2sByteSent:Number = (
+ _c2sSendCount * NDTConstants.PREDEFINED_BUFFER_SIZE
+ + (NDTConstants.PREDEFINED_BUFFER_SIZE - _c2sBytesNotSent));
+
+ TestResults.ndt_test_results::c2sSpeed = (c2sByteSent * NDTConstants.BYTES2BITS);
+ }

private function startTest():void {
if (!_msg.readHeader(_ctlSocket))
@@ -267,9 +284,10 @@
removeCtlSocketOnReceivedDataListener();

_c2sTimer.start();
+ _speedUpdateTimer.start();
// Record start time right before it starts sending data, to be as
// accurate as possible.
- _c2sTestDuration = getTimer();
+ _c2sTestStartTime = getTimer();

_testStage = SEND_DATA;
TestResults.appendDebugMsg("C2S test: SEND_DATA stage.");
@@ -288,9 +306,11 @@
private function closeC2SSocket():void {
// Record end time right after it stops sending data, to be as accurate as
// possible.
- _c2sTestDuration = getTimer() - _c2sTestDuration;
+ _c2sTestDuration = getTimer() - _c2sTestStartTime;
TestResults.appendDebugMsg(
"C2S test lasted " + _c2sTestDuration + " msec.");
+ _speedUpdateTimer.stop();
+ _speedUpdateTimer.removeEventListener(TimerEvent.TIMER, onSpeedUpdate);
_c2sTimer.stop();
_c2sTimer.removeEventListener(TimerEvent.TIMER, onC2STimeout);

=======================================
--- /branches/Issue131/flash-client/src/TestS2C.as Fri Feb 21 07:41:20 2014 UTC
+++ /branches/Issue131/flash-client/src/TestS2C.as Wed Mar 12 12:17:39 2014 UTC
@@ -31,6 +31,7 @@
public class TestS2C {
// Timer for single read operation.
private const READ_TIMEOUT:int = 15000; // 15sec
+ private const SPEED_UPDATE_TIMER:int = 1000; // ms

// Valid values for _testStage.
private static const PREPARE_TEST1:int = 0;
@@ -48,17 +49,18 @@
private var _ctlSocket:Socket;
private var _msg:Message;
private var _readTimer:Timer;
+ private var _speedUpdateTimer:Timer;
private var _s2cByteCount:int;
private var _s2cSocket:Socket;
private var _s2cTimer:Timer;
// Time to send data to client on the S2C socket.
private var _s2cTestDuration:Number;
+ private var _s2cTestStartTime:Number;
private var _s2cTestSuccess:Boolean;
private var _serverHostname:String;
private var _testStage:int;
private var _web100VarResult:String;

-
public function TestS2C(ctlSocket:Socket, serverHostname:String,
callerObj:NDTPController) {
_callerObj = callerObj;
@@ -67,6 +69,7 @@

_s2cTestSuccess = true; // Initially the test has not failed.
_s2cTestDuration = 0;
+ _s2cTestStartTime = 0;
_s2cByteCount = 0;
_web100VarResult = "";
}
@@ -172,6 +175,8 @@
}
_readTimer = new Timer(READ_TIMEOUT);
_readTimer.addEventListener(TimerEvent.TIMER, onS2CTimeout);
+ _speedUpdateTimer = new Timer(SPEED_UPDATE_TIMER);
+ _speedUpdateTimer.addEventListener(TimerEvent.TIMER, onSpeedUpdate);
_s2cTimer = new Timer(NDTConstants.S2C_DURATION);
_s2cTimer.addEventListener(TimerEvent.TIMER, onS2CTimeout);
_msg = new Message();
@@ -234,6 +239,13 @@
_readTimer.start();
receiveData();
}
+
+ private function onSpeedUpdate(e:TimerEvent):void {
+ _s2cTestDuration = getTimer() - _s2cTestStartTime;
+ TestResults.ndt_test_results::s2cSpeed = _s2cByteCount
+ * NDTConstants.BYTES2BITS
+ / _s2cTestDuration;
+ }

private function startTest():void {
if (!_msg.readHeader(_ctlSocket))
@@ -258,9 +270,10 @@

_readTimer.start();
_s2cTimer.start();
+ _speedUpdateTimer.start();
// Record start time right before it starts receiving data, to be as
// accurate as possible.
- _s2cTestDuration = getTimer();
+ _s2cTestStartTime = getTimer();

_testStage = RECEIVE_DATA;
TestResults.appendDebugMsg("S2C test: RECEIVE_DATA stage.");
@@ -290,9 +303,11 @@
// Record end time right after it stops receiving data, to be as accurate
// as possible.
_s2cTimer.stop();
- _s2cTestDuration = getTimer() - _s2cTestDuration;
+ _s2cTestDuration = getTimer() - _s2cTestStartTime;
TestResults.appendDebugMsg(
"S2C test lasted " + _s2cTestDuration + " msec.");
+ _speedUpdateTimer.stop();
+ _speedUpdateTimer.removeEventListener(TimerEvent.TIMER, onSpeedUpdate);
_readTimer.stop();
_readTimer.removeEventListener(TimerEvent.TIMER, onS2CTimeout);
_s2cTimer.removeEventListener(TimerEvent.TIMER, onS2CTimeout);
@@ -485,7 +500,6 @@
removeCtlSocketOnReceivedDataListener();

TestResults.appendDebugMsg("S2C test: END_TEST stage.");
-
if (_s2cTestSuccess)
TestResults.appendDebugMsg(
ResourceManager.getInstance().getString(



Archive powered by MHonArc 2.6.16.

Top of Page