From 054dbf53d4a16c85447281b70b50914346116e23 Mon Sep 17 00:00:00 2001 From: David Easter Date: Mon, 23 Feb 2015 23:23:51 -0500 Subject: [PATCH 1/3] Driver for load-testing application. --- support/client/lib/vwf.js | 2 + support/client/lib/vwf/view/load-test.js | 144 +++++++++++++++++++++++ 2 files changed, 146 insertions(+) create mode 100644 support/client/lib/vwf/view/load-test.js diff --git a/support/client/lib/vwf.js b/support/client/lib/vwf.js index 36e3e758a..795f6bd8a 100644 --- a/support/client/lib/vwf.js +++ b/support/client/lib/vwf.js @@ -391,6 +391,7 @@ active: false }, { library: "vwf/view/lesson", active: false}, + { library: "vwf/view/load-test", active: false}, { library: "vwf/view/threejs", disabledBy: ["vwf/model/glge", "vwf/view/glge"], active: false @@ -453,6 +454,7 @@ { library: "vwf/view/document", active: true }, { library: "vwf/view/editor", active: false }, { library: "vwf/view/lesson", active: false}, + { library: "vwf/view/load-test", active: false}, { library: "vwf/view/google-earth", active: false }, { library: "vwf/view/cesium", active: false }, { library: "vwf/view/blockly", active: false }, diff --git a/support/client/lib/vwf/view/load-test.js b/support/client/lib/vwf/view/load-test.js new file mode 100644 index 000000000..e49a67ea2 --- /dev/null +++ b/support/client/lib/vwf/view/load-test.js @@ -0,0 +1,144 @@ +"use strict"; + +// Copyright 2015 United States Government, as represented by the Secretary of Defense, Under +// Secretary of Defense (Personnel & Readiness). +// +// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except +// in compliance with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software distributed under the License +// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +// or implied. See the License for the specific language governing permissions and limitations under +// the License. + +/// @module vwf/view/document +/// @requires vwf/view + +define( [ "module", "vwf/view" ], function( module, view ) { + + return view.load( module, { + + initialize: function() { + this.state.enabled = false; + this.state.size = 1; + this.state.interval = 1; + this.state.clients = 0; + this.state.intervalID = undefined; + this.state.results = []; + }, + + addedChild: function( nodeID, childID, childName ) { + + if ( this.kernel.uri( nodeID ) === "http://vwf.example.com/client.vwf" ) { + clients.call( this, clients.call( this ) + 1 ); + } + + }, + + removedChild: function( nodeID, childID ) { + + if ( this.kernel.uri( nodeID ) === "http://vwf.example.com/client.vwf" ) { + clients.call( this, clients.call( this ) - 1 ); + } + + }, + + createdProperty: function( nodeID, propertyName, propertyValue ) { + + return this.initializedProperty( nodeID, propertyName, propertyValue ); + + }, + + initializedProperty: function( nodeID, propertyName, propertyValue ) { + + if ( propertyName !== "ping" || propertyValue !== null ) { + return this.satProperty( nodeID, propertyName, propertyValue ); + } + + }, + + satProperty: function( nodeID, propertyName, propertyValue ) { + + if ( nodeID === this.kernel.application() ) { + + switch( propertyName ) { + case "enabled": enabled.call( this, propertyValue ); break; + case "size": size.call( this, propertyValue ); break; + case "interval": interval.call( this, propertyValue ); break; + case "ping": pong.call( this, propertyValue ); break; + } + + } + + }, + + } ); + + function ping() { + this.kernel.setProperty( this.kernel.application(), "ping", +new Date ); + } + + function pong( pingTime ) { + this.state.results.push( { ping: pingTime, pong: +new Date } ); + } + + function enabled( value ) { + + var self = this; + + if ( value !== undefined ) { + + value = !! value; + + if ( value !== this.state.enabled ) { + + if ( value ) { + this.state.intervalID = setInterval( function() { ping.call( self ) }, interval.call( self ) * 1000 ); + } else if ( this.state.intervalID ) { + clearInterval( this.state.intervalID ); + this.state.intervalID = undefined; + } + + this.state.enabled = value; + + } + + } + + return this.state.enabled; + } + + function size( value ) { + + if ( value !== undefined ) { + value = +value || 1; + this.state.size = value; + } + + return this.state.size; + } + + function interval( value ) { + + if ( value !== undefined ) { + value = +value || 1; + this.state.interval = value; + } + + return this.state.interval; + } + + function clients( value ) { + + if ( value !== undefined ) { + value = +value || 1; + this.state.clients = value; + } + + return this.state.clients; + + } + +} ); From 2e73682ef46b82035ad135d44a2ab7ae8ec9147f Mon Sep 17 00:00:00 2001 From: David Easter Date: Tue, 24 Feb 2015 03:35:18 -0500 Subject: [PATCH 2/3] Record more results. --- support/client/lib/vwf/view/load-test.js | 73 +++++++++++++++++------- 1 file changed, 53 insertions(+), 20 deletions(-) diff --git a/support/client/lib/vwf/view/load-test.js b/support/client/lib/vwf/view/load-test.js index e49a67ea2..4d98acee6 100644 --- a/support/client/lib/vwf/view/load-test.js +++ b/support/client/lib/vwf/view/load-test.js @@ -21,26 +21,36 @@ define( [ "module", "vwf/view" ], function( module, view ) { return view.load( module, { initialize: function() { + this.state.enabled = false; + this.state.duration = 10; + this.state.size = 1; this.state.interval = 1; - this.state.clients = 0; + this.state.clients = {}; + + this.state.startTime = 0; + this.state.lastTime = 0; this.state.intervalID = undefined; + this.state.results = []; + this.state.others = 0; + this.state.pending = 0; + }, - addedChild: function( nodeID, childID, childName ) { + createdNode: function( nodeID, childID, childExtendsID, childImplementsIDs, childSource, childType, childIndex, childName, callback /* ready */ ) { - if ( this.kernel.uri( nodeID ) === "http://vwf.example.com/client.vwf" ) { - clients.call( this, clients.call( this ) + 1 ); + if ( this.kernel.uri( nodeID ) === "http://vwf.example.com/clients.vwf" ) { + this.state.clients[ childID ] = true; } }, - removedChild: function( nodeID, childID ) { + deletedNode: function( nodeID ) { - if ( this.kernel.uri( nodeID ) === "http://vwf.example.com/client.vwf" ) { - clients.call( this, clients.call( this ) - 1 ); + if ( this.state.clients[ nodeID ] ) { + delete this.state.clients[ nodeID ]; } }, @@ -65,6 +75,7 @@ define( [ "module", "vwf/view" ], function( module, view ) { switch( propertyName ) { case "enabled": enabled.call( this, propertyValue ); break; + case "duration": duration.call( this, propertyValue ); break; case "size": size.call( this, propertyValue ); break; case "interval": interval.call( this, propertyValue ); break; case "ping": pong.call( this, propertyValue ); break; @@ -77,11 +88,33 @@ define( [ "module", "vwf/view" ], function( module, view ) { } ); function ping() { - this.kernel.setProperty( this.kernel.application(), "ping", +new Date ); + + var time = +new Date; + + if ( time - this.state.startTime < this.state.duration * 1000 ) { + while( this.state.lastTime < time ) { + this.state.lastTime += this.state.interval * 1000; + this.kernel.setProperty( this.kernel.application(), "ping", time ); + this.state.pending++; + } + } else { + enabled.call( this, false ); + console.log( "Results", this.state ); + } + } function pong( pingTime ) { - this.state.results.push( { ping: pingTime, pong: +new Date } ); + + if ( enabled.call( this ) ) { + if ( this.kernel.client() === this.kernel.moniker() ) { + this.state.results.push( { ping: pingTime, pong: +new Date } ); + this.state.pending--; + } else { + this.state.others++; + } + } + } function enabled( value ) { @@ -95,6 +128,7 @@ define( [ "module", "vwf/view" ], function( module, view ) { if ( value !== this.state.enabled ) { if ( value ) { + this.state.startTime = this.state.lastTime = +new Date; this.state.intervalID = setInterval( function() { ping.call( self ) }, interval.call( self ) * 1000 ); } else if ( this.state.intervalID ) { clearInterval( this.state.intervalID ); @@ -110,35 +144,34 @@ define( [ "module", "vwf/view" ], function( module, view ) { return this.state.enabled; } - function size( value ) { + function duration( value ) { if ( value !== undefined ) { - value = +value || 1; - this.state.size = value; + value = +value || 10; + this.state.duration = value; } - return this.state.size; + return this.state.duration; } - function interval( value ) { + function size( value ) { if ( value !== undefined ) { value = +value || 1; - this.state.interval = value; + this.state.size = value; } - return this.state.interval; + return this.state.size; } - function clients( value ) { + function interval( value ) { if ( value !== undefined ) { value = +value || 1; - this.state.clients = value; + this.state.interval = value; } - return this.state.clients; - + return this.state.interval; } } ); From fec072799a2d4bb9cb03b4570d5dd6ffc9ef5616 Mon Sep 17 00:00:00 2001 From: David Easter Date: Tue, 24 Feb 2015 04:05:46 -0500 Subject: [PATCH 3/3] Configurable payload size. --- support/client/lib/vwf/view/load-test.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/support/client/lib/vwf/view/load-test.js b/support/client/lib/vwf/view/load-test.js index 4d98acee6..8da99692d 100644 --- a/support/client/lib/vwf/view/load-test.js +++ b/support/client/lib/vwf/view/load-test.js @@ -32,6 +32,7 @@ define( [ "module", "vwf/view" ], function( module, view ) { this.state.startTime = 0; this.state.lastTime = 0; this.state.intervalID = undefined; + this.state.payload = "*"; this.state.results = []; this.state.others = 0; @@ -78,13 +79,20 @@ define( [ "module", "vwf/view" ], function( module, view ) { case "duration": duration.call( this, propertyValue ); break; case "size": size.call( this, propertyValue ); break; case "interval": interval.call( this, propertyValue ); break; - case "ping": pong.call( this, propertyValue ); break; } } }, + calledMethod: function( nodeID, methodName, methodParameters, methodValue ) { + + if ( nodeID === this.kernel.application() && methodName == "ping" ) { + pong.call( this, methodParameters[ 0 ] ); + } + + }, + } ); function ping() { @@ -94,7 +102,7 @@ define( [ "module", "vwf/view" ], function( module, view ) { if ( time - this.state.startTime < this.state.duration * 1000 ) { while( this.state.lastTime < time ) { this.state.lastTime += this.state.interval * 1000; - this.kernel.setProperty( this.kernel.application(), "ping", time ); + this.kernel.callMethod( this.kernel.application(), "ping", [ time, this.state.payload ] ); this.state.pending++; } } else { @@ -159,6 +167,8 @@ define( [ "module", "vwf/view" ], function( module, view ) { if ( value !== undefined ) { value = +value || 1; this.state.size = value; + this.state.payload = ""; + for ( var i = 0; i < value; i++ ) { this.state.payload += "*" } } return this.state.size;