Skip to content
This repository was archived by the owner on Feb 8, 2025. It is now read-only.

Commit 0554305

Browse files
authored
Update README.md
1 parent ab551fd commit 0554305

File tree

1 file changed

+60
-71
lines changed

1 file changed

+60
-71
lines changed

README.md

Lines changed: 60 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ File1.cs
4141
.editorconfig
4242
```
4343

44-
### Writing (applies to Slnx 2.0, see below code block for Slnx 3.0)
44+
### Writing (applies to Slnx 3.0)
4545
```cs
4646
using Slnx;
4747
using System.Text.Json;
@@ -57,6 +57,7 @@ folder.AddProject(new Project("./DockerCompose/DockerCompose.dcproj", typeGuid:
5757
var moreFolders = new Folder("C++");
5858
moreFolders.AddFiles(["util.cpp", "util.h", "data.cc", "data.h"]);
5959
folder.AddFiles(["File1.cs", "File2.cs"]);
60+
folder.AddFolder(moreFolders);
6061

6162
factory.AddFolder(folder);
6263
factory.AddProjectWithPathOnly("Slnx/Slnx.csproj");
@@ -69,58 +70,8 @@ File.AppendAllText("OutputSlnx.txt", content);
6970
var model = SlnxModel.Load(File.ReadAllText("OutputSlnx.txt"));
7071
Console.WriteLine(JsonSerializer.Serialize(model));
7172
```
72-
#### For Slnx 3.0
73-
Note: The constructor of the `Project` class was slightly changed in Slnx 3.0. Change this:
74-
```cs
75-
// ...
76-
folder.AddProject(new Project("./DockerCompose/DockerCompose.dcproj", typeGuid: Guid.NewGuid(), config: new(solution: "*|*", project: "*|*|Deploy")));
77-
var moreFolders = new Folder("C++");
78-
```
79-
to:
80-
```cs
81-
// ...
82-
folder.AddProject(new Project("./DockerCompose/DockerCompose.dcproj", /*HERE -->*/type: Guid.NewGuid().ToString(), /*<-- HERE*/ config: new(solution: "*|*", project: "*|*|Deploy")));
83-
var moreFolders = new Folder("C++");
84-
```
73+
The program will generate a file named `OutputSlnx.txt` with these contents:
8574

86-
Starting with Slnx 3.0, you can convert `SlnxModel` to `string` asynchronously:
87-
```cs
88-
// ...
89-
factory.AddProjectWithPathOnly("App/App.shproj");
90-
91-
string content = await factory.AsModel().StoreAsync(); // <---
92-
File.AppendAllText("OutputSlnx.txt", content);
93-
```
94-
95-
### Writing (applies to Slnx 1.0)
96-
```cs
97-
using Slnx;
98-
99-
var factory = new SlnxFactory();
100-
factory.Folders.Add(new Folder("Solution Items", new[]
101-
{
102-
new Project("./CSharp/CSharp.csproj"),
103-
new Project("./VB.NET/VB.NET.vbproj"),
104-
new Project("./DockerCompose/DockerCompose.dcproj", Guid.NewGuid(), new(solution: "*|*", project: "*|*|Deploy"))
105-
}, new[]
106-
{
107-
new Folder("C++", Array.Empty<Project>(), Array.Empty<Folder>(), new[]
108-
{
109-
"util.cpp",
110-
"util.h",
111-
"data.cc",
112-
"data.h"
113-
})
114-
}, new string[] { "File1.cs", "File2.cs" }));
115-
116-
factory.Projects.Add(new Project("Slnx/Slnx.csproj"));
117-
factory.Projects.Add(new Project("App/App.shproj"));
118-
119-
var model = factory.AsModel();
120-
model.Store("OutputSlnx.txt");
121-
```
122-
123-
Both of these programs will generate `OutputSlnx.txt` with the following contents:
12475
```
12576
<Solution>
12677
<Project Path="Slnx/Slnx.csproj" />
@@ -144,40 +95,78 @@ Both of these programs will generate `OutputSlnx.txt` with the following content
14495
```
14596

14697
# Contributing
147-
Bug reports, suggestions, questions and other feedback are welcome.
98+
Bug reports, feature suggestions, questions, and other feedback are welcome.
14899

149100
# Compatibility
150101
Slnx uses the .NET 6.0 Runtime, but it works fine for preceding versions, including .NET 7.0, 8.0, and future releases.
151102

152103
# Benchmarking
153-
This is the benchmark for SLNX version 2.0, using `BenchmarkDotNet`. Benchmarks are found in the `./benchmark` folder.
154-
### Read
104+
105+
## Read Benchmark
106+
Input:
107+
```xml
108+
<Solution>
109+
<Folder Name="Solution Items">
110+
<File Path="File1.cs" />
111+
<File Path=".editorconfig" />
112+
<Project Path="File.csproj" />
113+
<Folder Name="Test">
114+
<File Path=".editorconfig" />
115+
<File Path="data.cs" />
116+
</Folder>
117+
</Folder>
118+
</Solution>
155119
```
156120

157-
BenchmarkDotNet v0.13.12, Windows 11 (10.0.22631.2861/23H2/2023Update/SunValley3)
121+
Benchmark result:
122+
```
123+
124+
BenchmarkDotNet v0.14.0, Windows 11 (10.0.22631.2861/23H2/2023Update/SunValley3)
158125
AMD Ryzen 7 4700U with Radeon Graphics, 1 CPU, 8 logical and 8 physical cores
159-
.NET SDK 8.0.204
160-
[Host] : .NET 8.0.4 (8.0.424.16909), X64 RyuJIT AVX2
161-
DefaultJob : .NET 8.0.4 (8.0.424.16909), X64 RyuJIT AVX2
126+
.NET SDK 8.0.303
127+
[Host] : .NET 8.0.7 (8.0.724.31311), X64 RyuJIT AVX2
128+
DefaultJob : .NET 8.0.7 (8.0.724.31311), X64 RyuJIT AVX2
129+
130+
131+
```
132+
| Method | Mean | Error | StdDev | Gen0 | Allocated |
133+
|------------ |---------:|----------:|----------:|-------:|----------:|
134+
| ReadBenchie | 4.486 μs | 0.0301 μs | 0.0267 μs | 7.1106 | 14.55 KB |
135+
136+
## Write Benchmark
137+
Code:
138+
```cs
139+
var factory = new SlnxFactory();
162140

141+
var folder = new Folder("Solution Items");
142+
folder.AddProjectWithPathOnly("./CSharp/CSharp.csproj");
143+
folder.AddProjectWithPathOnly("./VB.NET/VB.NET.vbproj");
144+
folder.AddProject(new Project("./DockerCompose/DockerCompose.dcproj", type: null, config: new(solution: "*|*", project: "*|*|Deploy")));
145+
var moreFolders = new Folder("C++");
146+
moreFolders.AddFiles(["util.cpp", "util.h", "data.cc", "data.h"]);
147+
folder.AddFiles(["File1.cs", "File2.cs"]);
148+
folder.AddFolder(moreFolders);
149+
150+
factory.AddFolder(folder);
151+
factory.AddProjectWithPathOnly("Slnx/Slnx.csproj");
152+
factory.AddProjectWithPathOnly("App/App.shproj");
163153

154+
_ = factory.AsModel().Store();
164155
```
165-
| Method | Mean | Error | StdDev | Gen0 | Allocated |
166-
|-------- |---------:|----------:|----------:|-------:|----------:|
167-
| Execute | 4.469 μs | 0.0834 μs | 0.0739 μs | 6.8970 | 14.17 KB |
156+
To provide the accurate benchmark, we're not saving or logging the result anywhere like console or file - we're
157+
just focusing on how fast Slnx can export the SlnxFactory instance as a string.
168158

169-
### Write
159+
Benchmark result:
170160
```
171161
172-
BenchmarkDotNet v0.13.12, Windows 11 (10.0.22631.2861/23H2/2023Update/SunValley3)
162+
BenchmarkDotNet v0.14.0, Windows 11 (10.0.22631.2861/23H2/2023Update/SunValley3)
173163
AMD Ryzen 7 4700U with Radeon Graphics, 1 CPU, 8 logical and 8 physical cores
174-
.NET SDK 8.0.204
175-
[Host] : .NET 8.0.4 (8.0.424.16909), X64 RyuJIT AVX2
176-
DefaultJob : .NET 8.0.4 (8.0.424.16909), X64 RyuJIT AVX2
164+
.NET SDK 8.0.303
165+
[Host] : .NET 8.0.7 (8.0.724.31311), X64 RyuJIT AVX2
166+
DefaultJob : .NET 8.0.7 (8.0.724.31311), X64 RyuJIT AVX2
177167
178168
179169
```
180-
| Method | Mean | Error | StdDev | Gen0 | Allocated |
181-
|-------- |---------:|----------:|----------:|--------:|----------:|
182-
| Execute | 8.763 μs | 0.1065 μs | 0.0944 μs | 17.6392 | 36.2 KB |
183-
170+
| Method | Mean | Error | StdDev | Gen0 | Allocated |
171+
|------------- |---------:|----------:|----------:|-------:|----------:|
172+
| WriteBenchie | 4.841 μs | 0.0371 μs | 0.0310 μs | 9.4299 | 19.33 KB |

0 commit comments

Comments
 (0)