fix benchmark.

This commit is contained in:
Christopher Jeffrey
2013-08-11 05:30:04 -05:00
parent 15f6833598
commit 791127bc88
4 changed files with 64 additions and 23 deletions
+16 -3
View File
@@ -1,9 +1,15 @@
/**
* term.js
* Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
*/
var element = {
createElement: function() { return element; },
appendChild: function() {},
removeChild: function() {},
addEventListener: function() {},
removeEventListener: function() {},
setAttribute: function() {},
style: {}
};
@@ -12,13 +18,20 @@ window.navigator = { userAgent: '' };
window.document = element;
window.document.body = element;
var Terminal = require('../static/term');
element.ownerDocument = window.document;
window.document.defaultView = window;
var Terminal = require('../lib/term');
Terminal.cursorBlink = false;
var data = require('./data').data;
var term = new Terminal(250, 100);
term.open();
var term = new Terminal({
cols: 250,
rows: 100
});
term.open(element);
var time = new Date;
var t = 10;
+27 -9
View File
@@ -1,11 +1,26 @@
<!doctype html>
<title>tty.js test</title>
<link rel="stylesheet" href="style.css">
<title>term.js test</title>
<style>
body > div { float: left; }
h1 { margin-bottom: 20px; }
h1 {
margin-bottom: 20px;
font: 20px/1.5 sans-serif;
}
.terminal {
float: left;
border: #000 solid 5px;
font-family: "DejaVu Sans Mono", "Liberation Mono", monospace;
font-size: 11px;
color: #f0f0f0;
background: #000;
}
.terminal-cursor {
color: #000;
background: #f0f0f0;
}
</style>
<h1>tty.js test</h1>
<h1>term.js test</h1>
<script src="term.js"></script>
<script src="data.js"></script>
<script>
@@ -16,11 +31,14 @@
Terminal.cursorBlink = false;
var term = new Terminal(80, 30);
var term = new Terminal({
cols: 80,
rows: 30
});
setTimeout(function() {
window.onload = function() {
// Add terminal.
term.open();
term.open(document.body);
// Run benchmark.
(function write() {
@@ -39,6 +57,6 @@
term.writeln('Writes: ' + l + '.');
term.writeln('Average (?): 28.5k (for ~2.5k writes).');
}
}, 500);
};
}).call(this);
</script>
+13 -5
View File
@@ -1,8 +1,17 @@
var path = require('path')
/**
* term.js
* Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
*/
var http = require('http')
, path = require('path')
, fs = require('fs');
var express = require('express')
, app = express.createServer();
, term = require('../');
var app = express()
, server = http.createServer(app);
app.use(function(req, res, next) {
var setHeader = res.setHeader;
@@ -19,7 +28,6 @@ app.use(function(req, res, next) {
});
app.use(express.static(__dirname));
app.use(term.middleware());
app.use(express.static(__dirname + '/../lib'));
app.listen(8080);
server.listen(8080);