Created
October 10, 2018 19:13
-
-
Save jerch/31f23538c5ca1a5079a78bbd627398ce to your computer and use it in GitHub Desktop.
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
const fs = require('fs'); | |
const Terminal = require('./lib/Terminal').Terminal; | |
class TestTerminal extends Terminal { | |
writeSync(data) { | |
this.writeBuffer.push(data); | |
this._innerWrite(); | |
} | |
} | |
function throughput(filename, impl, recycling) { | |
let data = fs.readFileSync(filename); | |
let content = ''; | |
while (content.length < 50000000) // test with +50MB | |
content += data.toString('UTF-8'); | |
const terminal = new TestTerminal({ | |
cols: 80, | |
rows: 25, | |
scrollback: 1000, | |
experimentalBufferLineImpl: impl, | |
experimentalPushRecycling: recycling | |
}); | |
let start = new Date(); | |
terminal.writeSync(content); | |
let duration = (new Date()) - (start); | |
console.log({ | |
BufferLineType: impl, | |
Recycling: recycling, | |
Throughput: Number(1000/duration*content.length/1024/1024).toFixed(2) + ' MB/s', | |
File: filename, | |
Duration: duration, | |
Size: content.length | |
}); | |
} | |
throughput('./benchmark_data1', 'JsArray', false) | |
throughput('./benchmark_data1', 'TypedArray', false) | |
throughput('./benchmark_data1', 'JsArray', true) | |
throughput('./benchmark_data1', 'TypedArray', true) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment