-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add dezalgo slide and add other metrics to performance test runner
- Loading branch information
Showing
5 changed files
with
78 additions
and
29 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
async function* dezalgo (iterator) { | ||
for await (const item of iterator) { | ||
await new Promise(setImmediate) | ||
yield item | ||
} | ||
} |
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 |
---|---|---|
@@ -1,25 +1,54 @@ | ||
const { spawn } = require('child_process') | ||
|
||
const MeasureStream = require('./measure-stream') | ||
|
||
// const { join } = require('path') | ||
// const { spawn } = require('child_process') | ||
// | ||
// module.exports = (test, mode) => { | ||
// const gauge = new Measure(mode) | ||
// | ||
// const proc = spawn('node', ['container.js', test, mode], { | ||
// cwd: __dirname | ||
// }) | ||
// proc.stdout.pipe(gauge) | ||
// | ||
// return gauge.data | ||
// } | ||
|
||
module.exports = (test, mode) => { | ||
const gauge = new MeasureStream(mode) | ||
let lastCpu = process.cpuUsage() | ||
|
||
const computers = { | ||
bps (last, chunk) { | ||
return last + chunk.length | ||
}, | ||
|
||
rss (last, next) { | ||
return process.memoryUsage().rss | ||
}, | ||
|
||
heapTotal (last, next) { | ||
return process.memoryUsage().heapTotal | ||
}, | ||
|
||
user (last) { | ||
if (last === 0) lastCpu = process.cpuUsage() | ||
return process.cpuUsage(lastCpu).user | ||
}, | ||
|
||
system (last) { | ||
if (last === 0) lastCpu = process.cpuUsage() | ||
return process.cpuUsage(lastCpu).system | ||
} | ||
} | ||
|
||
module.exports = (test, metric, mode) => { | ||
const computer = computers[metric] | ||
if (!computer) throw new Error(`Unknown metric "${metric}"`) | ||
|
||
const gauge = new MeasureStream(mode, computer) | ||
|
||
requireAndRun(test, mode, gauge) | ||
// spawnAndRun(test, mode, gauge) | ||
|
||
return gauge.data | ||
} | ||
|
||
function requireAndRun (test, mode, gauge) { | ||
const producer = require(`./${test}/producer`) | ||
const run = require(`./${test}/${mode}`) | ||
run(producer(), gauge) | ||
|
||
return gauge.data | ||
} | ||
|
||
function spawnAndRun (test, mode, gauge) { | ||
const proc = spawn('node', ['container.js', test, mode], { | ||
cwd: __dirname | ||
}) | ||
proc.stdout.pipe(gauge) | ||
} |
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
060f38e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to following URLs: