diff --git a/performance/lib/add_email.js b/performance/lib/add_email.js index 651bffdacde1c984112be57f5b9da94314047b5f..11221b1610a71d124da917c7a77291c377825648 100644 --- a/performance/lib/add_email.js +++ b/performance/lib/add_email.js @@ -1,4 +1,4 @@ exports.startFunc = function(cfg, cb) { // XXX: write me - setTimeout(function() { cb(); }, 10); + setTimeout(function() { cb(true); }, 10); }; diff --git a/performance/lib/include_only.js b/performance/lib/include_only.js index 651bffdacde1c984112be57f5b9da94314047b5f..3ca96fe376e27eae8820e3912cbbfd1bd2579c56 100644 --- a/performance/lib/include_only.js +++ b/performance/lib/include_only.js @@ -1,4 +1,70 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (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.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla BrowserID. + * + * The Initial Developer of the Original Code is Mozilla. + * Portions created by the Initial Developer are Copyright (C) 2011 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Lloyd Hilaiel <lloyd@hilaiel.com> + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* this file is the "include_only" activity, which simulates the load + * of an RP including include.js. */ + +var +http = require('http'), +https = require('https'), +url = require('url'); + exports.startFunc = function(cfg, cb) { - // XXX: write me - setTimeout(function() { cb(); }, 10); + var uObj; + var meth; + try { + uObj = url.parse(cfg.browserid); + meth = uObj.protocol === 'http:' ? http : https; + } catch(e) { + cb(false); + return; + } + + meth.get({ + host: uObj.hostname, + port: uObj.port, + path: '/include.js' + }, function (res) { + if (res.statusCode != 200) { + cb(false); + } else { + // XXX: check the checksum of body? + cb(true); + } + }).on('error', function(e) { + cb(false); + }); }; diff --git a/performance/lib/reauth.js b/performance/lib/reauth.js index 651bffdacde1c984112be57f5b9da94314047b5f..11221b1610a71d124da917c7a77291c377825648 100644 --- a/performance/lib/reauth.js +++ b/performance/lib/reauth.js @@ -1,4 +1,4 @@ exports.startFunc = function(cfg, cb) { // XXX: write me - setTimeout(function() { cb(); }, 10); + setTimeout(function() { cb(true); }, 10); }; diff --git a/performance/lib/reset_pass.js b/performance/lib/reset_pass.js index 651bffdacde1c984112be57f5b9da94314047b5f..11221b1610a71d124da917c7a77291c377825648 100644 --- a/performance/lib/reset_pass.js +++ b/performance/lib/reset_pass.js @@ -1,4 +1,4 @@ exports.startFunc = function(cfg, cb) { // XXX: write me - setTimeout(function() { cb(); }, 10); + setTimeout(function() { cb(true); }, 10); }; diff --git a/performance/lib/signin.js b/performance/lib/signin.js index 651bffdacde1c984112be57f5b9da94314047b5f..11221b1610a71d124da917c7a77291c377825648 100644 --- a/performance/lib/signin.js +++ b/performance/lib/signin.js @@ -1,4 +1,4 @@ exports.startFunc = function(cfg, cb) { // XXX: write me - setTimeout(function() { cb(); }, 10); + setTimeout(function() { cb(true); }, 10); }; diff --git a/performance/lib/signup.js b/performance/lib/signup.js index 651bffdacde1c984112be57f5b9da94314047b5f..11221b1610a71d124da917c7a77291c377825648 100644 --- a/performance/lib/signup.js +++ b/performance/lib/signup.js @@ -1,4 +1,4 @@ exports.startFunc = function(cfg, cb) { // XXX: write me - setTimeout(function() { cb(); }, 10); + setTimeout(function() { cb(true); }, 10); }; diff --git a/performance/run.js b/performance/run.js index 03d3786095885a7a0ffb967136952a0056823c3d..470b143b134153911911293b087c8e3927d7ec75 100755 --- a/performance/run.js +++ b/performance/run.js @@ -64,8 +64,8 @@ if (args.h) { // global configuration const configuration = { - verifier: argv.v ? argv.v : argv.s + "/verify", - browserid: argv.s + verifier: args.v ? args.v : args.s + "/verify", + browserid: args.s }; // last time we updated stats and added work if necc. @@ -164,18 +164,23 @@ function poll() { } // start the activity! outstanding++; - activity[act].startFunc(configuration, function() { + activity[act].startFunc(configuration, function(success) { outstanding--; - if (undefined === completed[act]) completed[act] = 0; - completed[act]++; + if (undefined === completed[act]) completed[act] = [ 0, 0 ]; + completed[act][success ? 0 : 1]++; }); } + var numErrors = 0; + function updateAverages(elapsed) { if (!iterations) return; var numActCompleted = 0; - Object.keys(completed).forEach(function(k) { numActCompleted += completed[k]; }); + Object.keys(completed).forEach(function(k) { + numActCompleted += completed[k][0]; + numErrors += completed[k][1]; + }); completed = { }; var avgUsersThisPeriod = (numActCompleted / activitiesPerUserPerSecond) * (elapsed / 1000); @@ -193,7 +198,8 @@ function poll() { function outputAverages() { console.log("\t", averages[0].toFixed(2), "\t", averages[1].toFixed(2), - "\t", averages[2].toFixed(2)); + "\t", averages[2].toFixed(2), + "\t", numErrors ? "(" + numErrors + " ERRORS!)" : ""); } // ** how much time has elapsed since the last poll?