XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

XFESystem

【Rust】XFE系统,基于Rust和汇编

公开
关注 0 Fork 0 Star 0
返回提交历史

XFEstudio/XFESystem

Isolate warmed line-cache allocation measurements from the test worker

88e836c
XFE工作室室长 <mail@xfegzs.com>
提交于

代码差异

1 个文件 +17 -8
Modified Tests/XFESystem.Desktop.Tests/TextLineIndexTests.cs +17 -8
@@ -32,13 +32,22 @@ public sealed class TextLineIndexTests
32 32 [Fact]
33 33 public void RepeatedLongDocumentScrollReadsReuseVisibleLinesWithoutSplittingDocumentAgain()
34 34 {
35 string text = string.Join('\n', Enumerable.Range(0, 3000).Select(i => $"Line {i} some text"));
36 var index = new TextLineIndex(text);
37 for (int line = 0; line < 40; line++) _ = index.DisplayLine(line);
38 long before = GC.GetAllocatedBytesForCurrentThread();
39 for (int iteration = 0; iteration < 1000; iteration++)
40 for (int line = 0; line < 40; line++) _ = index.DisplayLine(line);
41 Assert.Equal(0, GC.GetAllocatedBytesForCurrentThread() - before);
42 Assert.Equal(3000, index.Count);
35 long allocated = -1; int count = 0;
36 // Measure a warmed render thread, separate from the runner's reused
37 // worker thread and its first-use/JIT work. Keep the zero-byte limit.
38 var worker = new Thread(() =>
39 {
40 string text = string.Join('\n', Enumerable.Range(0, 3000).Select(i => $"Line {i} some text"));
41 var index = new TextLineIndex(text);
42 for (int iteration = 0; iteration < 256; iteration++)
43 for (int line = 0; line < 40; line++) _ = index.DisplayLine(line);
44 long before = GC.GetAllocatedBytesForCurrentThread();
45 for (int iteration = 0; iteration < 1000; iteration++)
46 for (int line = 0; line < 40; line++) _ = index.DisplayLine(line);
47 allocated = GC.GetAllocatedBytesForCurrentThread() - before;
48 count = index.Count;
49 });
50 worker.Start(); worker.Join();
51 Assert.Equal(0, allocated); Assert.Equal(3000, count);
43 52 }
44 53 }