| 1 | <!doctype html> |
| 2 | <title>term.js test</title> |
| 3 | <style> |
| 4 | h1 { |
| 5 | margin-bottom: 20px; |
| 6 | font: 20px/1.5 sans-serif; |
| 7 | } |
| 8 | </style> |
| 9 | <h1>term.js test</h1> |
| 10 | <script src="term.js"></script> |
| 11 | <script src="data.js"></script> |
| 12 | <script> |
| 13 | ;(function() { |
| 14 | var time = new Date |
| 15 | , l = data.length * 0.9 | 0 |
| 16 | , i = 0; |
| 17 | |
| 18 | Terminal.cursorBlink = false; |
| 19 | |
| 20 | var term = new Terminal({ |
| 21 | cols: 80, |
| 22 | rows: 30, |
| 23 | useStyle: true |
| 24 | }); |
| 25 | |
| 26 | window.onload = function() { |
| 27 | // Add terminal. |
| 28 | term.open(document.body); |
| 29 | |
| 30 | // Run benchmark. |
| 31 | (function write() { |
| 32 | if (i >= l) return next(); |
| 33 | term.write(data[i]); |
| 34 | i++; |
| 35 | setTimeout(write, 1); |
| 36 | })(); |
| 37 | |
| 38 | // Results. |
| 39 | function next() { |
| 40 | term.write('\x1b[2J'); |
| 41 | term.reset(); |
| 42 | term.refresh(0, term.rows - 1); |
| 43 | term.writeln('Completed in ' + (new Date - time) + '.'); |
| 44 | term.writeln('Writes: ' + l + '.'); |
| 45 | term.writeln('Average (?): 28.5k (for ~2.5k writes).'); |
| 46 | } |
| 47 | }; |
| 48 | }).call(this); |
| 49 | </script> |