Skip to content

Instantly share code, notes, and snippets.

@jerch
Created October 10, 2018 19:13
Show Gist options
  • Save jerch/31f23538c5ca1a5079a78bbd627398ce to your computer and use it in GitHub Desktop.
Save jerch/31f23538c5ca1a5079a78bbd627398ce to your computer and use it in GitHub Desktop.
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