Browse Source

add csi parsing benchmark

xuty 4 năm trước cách đây
mục cha
commit
1260dfc4c2
2 tập tin đã thay đổi với 26 bổ sung3 xóa
  1. 26 3
      script/benchmark.dart
  2. 0 0
      script/cmatrix.txt

+ 26 - 3
script/benchmark.dart

@@ -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';

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 0 - 0
script/cmatrix.txt


Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác