-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement trace option like mysql client (#290)
- Loading branch information
Showing
5 changed files
with
127 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
'use strict'; | ||
|
||
var Benchmark = require('benchmark'); | ||
var http = require('http'); | ||
var urllib = require('../'); | ||
var suite = new Benchmark.Suite(); | ||
var agent = new http.Agent({ | ||
keepAlive: true, | ||
keepAliveMsecs: 5000, | ||
maxSockets: 100, | ||
timeout: 5000, | ||
}); | ||
|
||
// start your nginx listen 8080 with hello,world | ||
|
||
function request(trace, deferred) { | ||
urllib.request('http://127.0.0.1:8080', { | ||
timeout: 20000, | ||
trace: trace, | ||
agent: agent, | ||
}).then(function() { | ||
deferred.resolve(); | ||
}); | ||
} | ||
|
||
suite | ||
.add('warm up agent', { | ||
defer: true, | ||
fn: function(deferred) { | ||
request(false, deferred); | ||
} | ||
}) | ||
.add('request with no trace', { | ||
defer: true, | ||
fn: function(deferred) { | ||
request(false, deferred); | ||
} | ||
}) | ||
.add('request with trace', { | ||
defer: true, | ||
fn: function(deferred) { | ||
request(true, deferred); | ||
} | ||
}) | ||
.on('cycle', function(event) { | ||
console.log(String(event.target)); | ||
}) | ||
.on('complete', function() { | ||
console.log('Fastest is ' + this.filter('fastest').map('name')); | ||
}) | ||
// run async | ||
.run({ 'async': true }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters