Skip to content

Commit 8bf752f

Browse files
Rework presenters
1 parent 2f545a6 commit 8bf752f

28 files changed

+241
-389
lines changed

src/Perfolizer/Perfolizer.Tests/Helpers/CpuBrandHelperTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public Task CpuBrandHelperTest01()
2828
captions.AppendLine(cpu.ToFullBrandName());
2929
}
3030

31-
var settings = VerifyHelper.CreateSettings("Cpu");
31+
var settings = VerifyHelper.CreateSettings("_");
3232
return Verifier.Verify(captions.ToString(), settings);
3333
}
3434
}

src/Perfolizer/Perfolizer.Tests/Perfonar/PerfonarSimpleTests.cs

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,32 @@
44
using Perfolizer.Metrology;
55
using Perfolizer.Models;
66
using Perfolizer.Perfonar.Base;
7-
using Perfolizer.Perfonar.Presenting;
87
using Perfolizer.Perfonar.Tables;
9-
using Perfolizer.Presenting;
108

119
namespace Perfolizer.Tests.Perfonar;
1210

1311
public class PerfonarSimpleTests : PerfonarTestsBase
1412
{
13+
private PerfonarTableConfig tableConfig = new()
14+
{
15+
ColumnDefinitions =
16+
[
17+
new PerfonarColumnDefinition(".engine") { Cloud = "primary", IsSelfExplanatory = true },
18+
new PerfonarColumnDefinition(".host.os") { Cloud = "primary", IsSelfExplanatory = true },
19+
new PerfonarColumnDefinition(".host.cpu") { Cloud = "primary", IsSelfExplanatory = true },
20+
new PerfonarColumnDefinition(".benchmark") { Cloud = "secondary" },
21+
new PerfonarColumnDefinition(".job") { Cloud = "secondary", Compressed = true },
22+
new PerfonarColumnDefinition("=center"),
23+
new PerfonarColumnDefinition("=spread")
24+
]
25+
};
26+
1527
[Fact]
16-
public Task PerfonarSimpleTableTest()
28+
public async Task PerfonarSimpleTableTest()
1729
{
18-
var table = new PerfonarTable(CreateRoot());
19-
var presenter = new StringPresenter();
20-
new PerfonarMarkdownTablePresenter(presenter).Present(table, new PerfonarTableStyle());
21-
return Verify(presenter.Dump(), CreateSettings());
30+
var table = new PerfonarTable(CreateRoot(), tableConfig);
31+
string markdown = table.ToMarkdown();
32+
await Verify(markdown, CreateSettings());
2233
}
2334

2435
[Fact]
@@ -42,22 +53,6 @@ private static EntryInfo CreateRoot()
4253

4354
EntryInfo CreateEntry(string benchmarkId) => new EntryInfo
4455
{
45-
Meta = new PerfonarMeta
46-
{
47-
Table = new PerfonarTableConfig
48-
{
49-
ColumnDefinitions =
50-
[
51-
new PerfonarColumnDefinition(".engine") { Cloud = "primary", IsSelfExplanatory = true },
52-
new PerfonarColumnDefinition(".host.os") { Cloud = "primary", IsSelfExplanatory = true },
53-
new PerfonarColumnDefinition(".host.cpu") { Cloud = "primary", IsSelfExplanatory = true },
54-
new PerfonarColumnDefinition(".benchmark") { Cloud = "secondary" },
55-
new PerfonarColumnDefinition(".job") { Cloud = "secondary", Compressed = true },
56-
new PerfonarColumnDefinition("=center"),
57-
new PerfonarColumnDefinition("=spread")
58-
]
59-
}
60-
},
6156
Identity = new IdentityInfo
6257
{
6358
RunId = runId,
@@ -107,7 +102,9 @@ private class SimpleHostInfo : HostInfo
107102
}
108103

109104
[PublicAPI]
110-
private class SimpleExecutionInfo : ExecutionInfo { }
105+
private class SimpleExecutionInfo : ExecutionInfo
106+
{
107+
}
111108

112109
[PublicAPI]
113110
private class SimpleBenchmarkInfo : BenchmarkInfo

src/Perfolizer/Perfolizer.Tests/Perfonar/PerfonarTableTests.cs

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,31 @@
22
using Perfolizer.Metrology;
33
using Perfolizer.Models;
44
using Perfolizer.Perfonar.Base;
5-
using Perfolizer.Perfonar.Presenting;
65
using Perfolizer.Perfonar.Tables;
7-
using Perfolizer.Presenting;
86
using Perfolizer.Tests.Infra;
97

108
namespace Perfolizer.Tests.Perfonar;
119

1210
public class PerfonarTableTests(ITestOutputHelper output) : PerfonarTestsBase
1311
{
12+
private PerfonarTableConfig tableConfig = new()
13+
{
14+
ColumnDefinitions =
15+
[
16+
new PerfonarColumnDefinition(".benchmark") { Cloud = "secondary" },
17+
new PerfonarColumnDefinition(".job") { Cloud = "secondary", Compressed = true },
18+
new PerfonarColumnDefinition("=center")
19+
]
20+
};
21+
1422
[Theory]
1523
[MemberData(nameof(EntryDataKeys))]
16-
public Task PerfonarTableTest(string key)
24+
public async Task PerfonarTableTest(string key)
1725
{
1826
var entry = EntryDataMap[key];
19-
var table = new PerfonarTable(entry);
20-
var presenter = new StringPresenter();
21-
new PerfonarMarkdownTablePresenter(presenter).Present(table, new PerfonarTableStyle());
22-
return VerifyString(key, presenter.Dump());
27+
var table = new PerfonarTable(entry, tableConfig);
28+
string markdown = table.ToMarkdown();
29+
await VerifyString(key, markdown);
2330
}
2431

2532
private static readonly IDictionary<string, EntryInfo> EntryDataMap = new Dictionary<string, EntryInfo>
@@ -34,21 +41,7 @@ public Task PerfonarTableTest(string key)
3441

3542
[UsedImplicitly] public static TheoryData<string> EntryDataKeys = TheoryDataHelper.Create(EntryDataMap.Keys);
3643

37-
private static EntryInfo Root() => new()
38-
{
39-
Meta = new PerfonarMeta
40-
{
41-
Table = new PerfonarTableConfig
42-
{
43-
ColumnDefinitions =
44-
[
45-
new PerfonarColumnDefinition(".benchmark") { Cloud = "secondary" },
46-
new PerfonarColumnDefinition(".job") { Cloud = "secondary", Compressed = true },
47-
new PerfonarColumnDefinition("=center")
48-
]
49-
}
50-
},
51-
};
44+
private static EntryInfo Root() => new();
5245

5346
private static EntryInfo Benchmark(string name, params string[] metrics)
5447
{
@@ -71,11 +64,11 @@ private class CustomBenchmarkInfo(string name) : BenchmarkInfo
7164
public string Name { get; set; } = name;
7265
}
7366

74-
private Task VerifyString(string key, string content)
67+
private async Task VerifyString(string key, string content)
7568
{
7669
output.WriteLine(content);
77-
var settings = VerifyHelper.CreateSettings("Perfonar");
70+
var settings = VerifyHelper.CreateSettings("_");
7871
settings.UseParameters(key);
79-
return Verify(content, settings);
72+
await Verify(content, settings);
8073
}
8174
}

src/Perfolizer/Perfolizer.Tests/Perfonar/PerfonarTestsBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ protected static Task VerifyPerfonar(EntryInfo entry, PerfonarSchema schema)
2121
return VerifyJson(json, CreateSettings());
2222
}
2323

24-
protected static VerifySettings CreateSettings() => VerifyHelper.CreateSettings("Perfonar");
24+
protected static VerifySettings CreateSettings() => VerifyHelper.CreateSettings("_");
2525
}
Lines changed: 4 additions & 148 deletions
Original file line numberDiff line numberDiff line change
@@ -56,43 +56,7 @@
5656
"metric": "Gc.CollectCount",
5757
"value": 3
5858
}
59-
],
60-
"meta": {
61-
"table": {
62-
"columnDefinitions": [
63-
{
64-
"selector": ".engine",
65-
"cloud": "primary",
66-
"isSelfExplanatory": true
67-
},
68-
{
69-
"selector": ".host.os",
70-
"cloud": "primary",
71-
"isSelfExplanatory": true
72-
},
73-
{
74-
"selector": ".host.cpu",
75-
"cloud": "primary",
76-
"isSelfExplanatory": true
77-
},
78-
{
79-
"selector": ".benchmark",
80-
"cloud": "secondary"
81-
},
82-
{
83-
"selector": ".job",
84-
"cloud": "secondary",
85-
"compressed": true
86-
},
87-
{
88-
"selector": "=center"
89-
},
90-
{
91-
"selector": "=spread"
92-
}
93-
]
94-
}
95-
}
59+
]
9660
},
9761
{
9862
"identity": {
@@ -145,43 +109,7 @@
145109
"metric": "Gc.CollectCount",
146110
"value": 3
147111
}
148-
],
149-
"meta": {
150-
"table": {
151-
"columnDefinitions": [
152-
{
153-
"selector": ".engine",
154-
"cloud": "primary",
155-
"isSelfExplanatory": true
156-
},
157-
{
158-
"selector": ".host.os",
159-
"cloud": "primary",
160-
"isSelfExplanatory": true
161-
},
162-
{
163-
"selector": ".host.cpu",
164-
"cloud": "primary",
165-
"isSelfExplanatory": true
166-
},
167-
{
168-
"selector": ".benchmark",
169-
"cloud": "secondary"
170-
},
171-
{
172-
"selector": ".job",
173-
"cloud": "secondary",
174-
"compressed": true
175-
},
176-
{
177-
"selector": "=center"
178-
},
179-
{
180-
"selector": "=spread"
181-
}
182-
]
183-
}
184-
}
112+
]
185113
},
186114
{
187115
"identity": {
@@ -234,43 +162,7 @@
234162
"metric": "Gc.CollectCount",
235163
"value": 3
236164
}
237-
],
238-
"meta": {
239-
"table": {
240-
"columnDefinitions": [
241-
{
242-
"selector": ".engine",
243-
"cloud": "primary",
244-
"isSelfExplanatory": true
245-
},
246-
{
247-
"selector": ".host.os",
248-
"cloud": "primary",
249-
"isSelfExplanatory": true
250-
},
251-
{
252-
"selector": ".host.cpu",
253-
"cloud": "primary",
254-
"isSelfExplanatory": true
255-
},
256-
{
257-
"selector": ".benchmark",
258-
"cloud": "secondary"
259-
},
260-
{
261-
"selector": ".job",
262-
"cloud": "secondary",
263-
"compressed": true
264-
},
265-
{
266-
"selector": "=center"
267-
},
268-
{
269-
"selector": "=spread"
270-
}
271-
]
272-
}
273-
}
165+
]
274166
},
275167
{
276168
"identity": {
@@ -323,43 +215,7 @@
323215
"metric": "Gc.CollectCount",
324216
"value": 3
325217
}
326-
],
327-
"meta": {
328-
"table": {
329-
"columnDefinitions": [
330-
{
331-
"selector": ".engine",
332-
"cloud": "primary",
333-
"isSelfExplanatory": true
334-
},
335-
{
336-
"selector": ".host.os",
337-
"cloud": "primary",
338-
"isSelfExplanatory": true
339-
},
340-
{
341-
"selector": ".host.cpu",
342-
"cloud": "primary",
343-
"isSelfExplanatory": true
344-
},
345-
{
346-
"selector": ".benchmark",
347-
"cloud": "secondary"
348-
},
349-
{
350-
"selector": ".job",
351-
"cloud": "secondary",
352-
"compressed": true
353-
},
354-
{
355-
"selector": "=center"
356-
},
357-
{
358-
"selector": "=spread"
359-
}
360-
]
361-
}
362-
}
218+
]
363219
}
364220
]
365221
}

0 commit comments

Comments
 (0)