Skip to content

Commit

Permalink
engines/dotnet: make it more idiomatic and improve perf
Browse files Browse the repository at this point in the history
Performance updates:

* Use EnumerateMatches instead of Matches when capture groups aren't
needed.
* Use Match w/ NextMatch instead of Matches when capture groups are
needed.
* Use EnumerateLines to avoid materializing strings for each line when
not necessary.

Idiom updates:

* Use switch statements/expressions instead of large cascading
if/elses.
* Use and slice spans instead of `List<byte>` manipulations.
* No need to explicitly use Stream.Read; it can instead copy the
input stream to a memory stream and get a span to the memory stream's
buffered data.
* Change comments to be structured XML comments so that they show up
for consumers in IntelliSense / docs / etc.
* Use Elapsed.TotalNanoseconds instead of a custom helper.
* Use Func<..> instead of custom delegates.
* Use ++ instead of += 1.
* Use record structs for simple POCOs.

Closes #10
  • Loading branch information
stephentoub authored and BurntSushi committed Dec 27, 2023
1 parent 79305bc commit 284eace
Show file tree
Hide file tree
Showing 3 changed files with 154 additions and 188 deletions.
18 changes: 9 additions & 9 deletions benchmarks/engines.toml
Original file line number Diff line number Diff line change
Expand Up @@ -277,15 +277,15 @@
name = "dotnet"
cwd = "../engines/dotnet"
[engine.version]
bin = "bin/Release/net7.0/main"
bin = "bin/Release/net8.0/main"
args = ["version"]
[engine.run]
bin = "bin/Release/net7.0/main"
bin = "bin/Release/net8.0/main"
args = ["interp"]
[[engine.dependency]]
bin = "dotnet"
args = ["--list-sdks"]
regex = '(?m)^7\.'
regex = '(?m)^8\.'
[[engine.build]]
bin = "dotnet"
args = ["build", "-c", "Release"]
Expand All @@ -302,15 +302,15 @@
name = "dotnet/compiled"
cwd = "../engines/dotnet"
[engine.version]
bin = "bin/Release/net7.0/main"
bin = "bin/Release/net8.0/main"
args = ["version"]
[engine.run]
bin = "bin/Release/net7.0/main"
bin = "bin/Release/net8.0/main"
args = ["compiled"]
[[engine.dependency]]
bin = "dotnet"
args = ["--list-sdks"]
regex = '(?m)^7\.'
regex = '(?m)^8\.'
[[engine.build]]
bin = "dotnet"
args = ["build", "-c", "Release"]
Expand All @@ -329,15 +329,15 @@
name = "dotnet/nobacktrack"
cwd = "../engines/dotnet"
[engine.version]
bin = "bin/Release/net7.0/main"
bin = "bin/Release/net8.0/main"
args = ["version"]
[engine.run]
bin = "bin/Release/net7.0/main"
bin = "bin/Release/net8.0/main"
args = ["nobacktrack"]
[[engine.dependency]]
bin = "dotnet"
args = ["--list-sdks"]
regex = '(?m)^7\.'
regex = '(?m)^8\.'
[[engine.build]]
bin = "dotnet"
args = ["build", "-c", "Release"]
Expand Down
Loading

0 comments on commit 284eace

Please sign in to comment.