|
|
@@ -1,9 +1,12 @@
|
|
|
+import 'dart:io';
|
|
|
+
|
|
|
import 'package:xterm/xterm.dart';
|
|
|
|
|
|
void main() {
|
|
|
- BenchmarkWrite().run();
|
|
|
- BenchmarkWrite2().run();
|
|
|
- BenchmarkWriteBuffer().run();
|
|
|
+ // BenchmarkWrite().run();
|
|
|
+ // BenchmarkWrite2().run();
|
|
|
+ // BenchmarkWriteBuffer().run();
|
|
|
+ BenchmarkWriteCMatrix().run();
|
|
|
}
|
|
|
|
|
|
abstract class Benchmark {
|
|
|
@@ -55,6 +58,26 @@ class BenchmarkWrite2 extends Benchmark {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+class BenchmarkWriteCMatrix extends Benchmark {
|
|
|
+ BenchmarkWriteCMatrix() {
|
|
|
+ data = File('script/cmatrix.txt').readAsStringSync();
|
|
|
+ }
|
|
|
+
|
|
|
+ static const cycle = 1 << 0;
|
|
|
+ late final String data;
|
|
|
+
|
|
|
+ String explain() {
|
|
|
+ return 'write ${data.length / 1024} kb CMatrix output to Terminal for $cycle time(s)';
|
|
|
+ }
|
|
|
+
|
|
|
+ void benchmark() {
|
|
|
+ final terminal = Terminal();
|
|
|
+ for (var i = 0; i < cycle; i++) {
|
|
|
+ terminal.write(data);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
class BenchmarkWriteBuffer extends Benchmark {
|
|
|
static const cycle = 1 << 20;
|
|
|
static const data = 'hello world';
|