loadtest
Advanced tools
Comparing version 3.0.1 to 3.0.2
@@ -8,3 +8,3 @@ "use strict"; | ||
// globals | ||
const log = new Log('debug'); | ||
const log = new Log('info'); | ||
@@ -11,0 +11,0 @@ |
@@ -17,3 +17,3 @@ 'use strict'; | ||
// globals | ||
const log = new Log('debug'); | ||
const log = new Log('info'); | ||
@@ -20,0 +20,0 @@ // constants |
@@ -20,3 +20,3 @@ 'use strict'; | ||
// globals | ||
const log = new Log('debug'); | ||
const log = new Log('info'); | ||
@@ -23,0 +23,0 @@ // constants |
@@ -385,2 +385,7 @@ 'use strict'; | ||
class HighResolutionTimer { | ||
/** | ||
* Create a timer with the given delay. | ||
* Important: will run once when started, then once every delayMs. | ||
*/ | ||
constructor(delayMs, callback) { | ||
@@ -393,3 +398,3 @@ this.delayMs = delayMs | ||
// start timer | ||
this.delayed(); | ||
setImmediate(() => this.delayed()) | ||
} | ||
@@ -406,6 +411,6 @@ | ||
this.counter ++; | ||
const diff = (Date.now() - this.start) - this.counter * this.delayMs; | ||
const diff = (Date.now() - this.start) - (this.counter - 1) * this.delayMs; | ||
const timeout = Math.floor(this.delayMs - diff); | ||
if (timeout <= 0) { | ||
return this.delayed(); | ||
return setImmediate(() => this.delayed()) | ||
} | ||
@@ -443,3 +448,3 @@ this.timer = setTimeout(() => this.delayed(), this.delayMs - diff); | ||
*/ | ||
function testTimer(callback) { | ||
function testTimerStop(callback) { | ||
const timer = new HighResolutionTimer(10, callback); | ||
@@ -449,2 +454,16 @@ timer.stop(); | ||
function testTimerRun(callback) { | ||
let run = 0 | ||
const start = Date.now() | ||
const timer = new HighResolutionTimer(100, () => { | ||
console.log('Run at %s', Date.now() - start) | ||
run++ | ||
}) | ||
setTimeout(() => { | ||
testing.equals(run, 3, callback) | ||
timer.stop() | ||
testing.success(callback) | ||
}, 250) | ||
} | ||
/** | ||
@@ -458,3 +477,4 @@ * Run package tests. | ||
testLatencyPercentiles, | ||
testTimer | ||
testTimerStop, | ||
testTimerRun, | ||
]; | ||
@@ -461,0 +481,0 @@ testing.run(tests, callback); |
@@ -17,3 +17,3 @@ 'use strict'; | ||
// globals | ||
const log = new Log('debug'); | ||
const log = new Log('info'); | ||
let latency; | ||
@@ -20,0 +20,0 @@ |
{ | ||
"name": "loadtest", | ||
"version": "3.0.1", | ||
"version": "3.0.2", | ||
"description": "Run load tests for your web application. Mostly ab-compatible interface, with an option to force requests per second. Includes an API for automated load testing.", | ||
@@ -21,3 +21,3 @@ "homepage": "https://github.com/alexfernandez/loadtest", | ||
"stdio": "^0.2.3", | ||
"testing": "^0.2.3", | ||
"testing": "^1.1.1", | ||
"websocket": "^1.0.22" | ||
@@ -24,0 +24,0 @@ }, |
@@ -34,4 +34,4 @@ 'use strict'; | ||
{ | ||
exports.test(testing.show); | ||
exports.test(); | ||
} | ||
80510
1876
+ Addedtesting@1.1.2(transitive)
- Removedtesting@0.2.3(transitive)
Updatedtesting@^1.1.1