Registry Mirror
Skip to content

Conversation

@vbreuss

@vbreuss vbreuss commented Nov 29, 2026

Copy link
Copy Markdown
Member

FileInfo.DirectoryName returned Directory?.FullName, so every access created a DirectoryInfoMock (including a container lookup) only to read the path of its location. It now returns the full path of the parent location directly, which is exactly the string Directory.FullName returned. The statistics are unchanged, as the nested Directory access was not recorded before either.

New tests check that DirectoryName equals Directory.FullName and Path.GetDirectoryName(FullName) for nested and relative paths, and that it returns the root for a file in the root directory.

Benchmark on Linux against main: Inspect (FileInfo.New plus Exists, Length, LastWriteTimeUtc, Name, DirectoryName) allocates 1,800 B -> 1,728 B (-4%); the time is within noise.

…nfo`

`FileInfo.DirectoryName` returned `Directory?.FullName`, so every access created a `DirectoryInfoMock` (including a container lookup) only to read the path of its location. It now returns the full path of the parent location directly, which is exactly the string `Directory.FullName` returned. The statistics are unchanged, as the nested `Directory` access was not recorded before either.

New tests check that `DirectoryName` equals `Directory.FullName` and `Path.GetDirectoryName(FullName)` for nested and relative paths, and that it returns the root for a file in the root directory.

Benchmark on Linux against `main`: Inspect (`FileInfo.New` plus `Exists`, `Length`, `LastWriteTimeUtc`, `Name`, `DirectoryName`) allocates 1,800 B -> 1,728 B (-4%); the time is within noise.
@vbreuss vbreuss self-assigned this Nov 29, 2026
@mergify

mergify Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

This pull request is merged.

@greptile-apps

greptile-apps Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

Confidence Score: 5/5 · The PR appears safe to merge.RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge.

Summary

FileInfoMock.DirectoryName now reads the parent location’s full path without creating a DirectoryInfoMock.

  • Mock file DirectoryName gets its parent path without a directory wrapper.

Reviews (1) · Last reviewed commit: "perf: compute `FileInfo.DirectoryName` w..." · Reviewed by Greptile

@vbreuss
vbreuss enabled auto-merge (squash) November 29, 2026 14:20
@vbreuss
vbreuss merged commit 709ecbd into main Nov 29, 2026
24 checks passed
@vbreuss
vbreuss deleted the perf/file-info-directory-name branch November 29, 2026 15:29
@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown

🚀 Benchmark Results

Compared to main, which ran on the same runner. Times that change by more than 10% are marked.

Memory

Benchmark main PR Δ
Initialize (N=100) 410,449 B 411,553 B 🔴 +1,104 B (±0%)
RoundTrip (Size=65536) 198,443 B 198,429 B 🟢 -14 B (±0%)
Inspect 1,800 B 1,728 B 🟢 -72 B (-4%)
Enumerate (N=1000&Pattern=*.txt) 279,985 B 279,987 B 🔴 +2 B (±0%)

Time

Benchmark main PR Δ
Enumerate (N=10&Pattern=*) 6.28 μs 4.84 μs 🟢 -23%
CompleteTestBenchmarks
Complete Mean Error StdDev Ratio Allocated Alloc Ratio
Testably 24.19 μs 0.212 μs 0.177 μs 1.00 46.13 KB 1.00
SystemIOAbstractions 77.50 μs 0.567 μs 0.503 μs 3.20 166.7 KB 3.61
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
AMD EPYC 9V74 3.69GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 11.0.100
  [Host] : .NET 10.0.15 (10.0.15, 10.0.1526.53008), X64 RyuJIT x86-64-v4

Job=InProcess  Toolchain=InProcessEmitToolchain  IterationCount=15  
LaunchCount=1  WarmupCount=10  

InitializationBenchmarks
Initialize N Mean Error StdDev Ratio Allocated Alloc Ratio
Testably 10 26.29 μs 0.775 μs 0.725 μs 1.00 50.03 KB 1.00
SystemIOAbstractions 10 21.57 μs 0.170 μs 0.159 μs 0.82 48.59 KB 0.97
Testably 100 214.78 μs 1.326 μs 1.107 μs 1.00 401.91 KB 1.00
SystemIOAbstractions 100 174.69 μs 4.876 μs 4.561 μs 0.81 392.78 KB 0.98
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
AMD EPYC 9V74 3.69GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 11.0.100
  [Host] : .NET 10.0.15 (10.0.15, 10.0.1526.53008), X64 RyuJIT x86-64-v4

Job=InProcess  Toolchain=InProcessEmitToolchain  IterationCount=15  
LaunchCount=1  WarmupCount=10  

MockCreationBenchmarks
CreateMock Mean Error StdDev Ratio Allocated Alloc Ratio
Testably 1.614 μs 0.0411 μs 0.0385 μs 1.00 6 KB 1.00
SystemIOAbstractions 3.731 μs 0.1070 μs 0.0948 μs 2.31 8.15 KB 1.36
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
AMD EPYC 9V74 3.69GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 11.0.100
  [Host] : .NET 10.0.15 (10.0.15, 10.0.1526.53008), X64 RyuJIT x86-64-v4

Job=InProcess  Toolchain=InProcessEmitToolchain  IterationCount=15  
LaunchCount=1  WarmupCount=10  

FileRoundTripBenchmarks
RoundTrip Size Mean Error StdDev Median Ratio Allocated Alloc Ratio
Testably 1024 5.459 μs 2.2853 μs 2.1376 μs 4.165 μs 1.13 4.71 KB 1.00
SystemIOAbstractions 1024 9.380 μs 4.3774 μs 4.0946 μs 7.296 μs 1.95 16.54 KB 3.51
Testably 65536 73.519 μs 0.4672 μs 0.3902 μs 73.532 μs 1.00 193.78 KB 1.00
SystemIOAbstractions 65536 64.782 μs 1.8724 μs 1.6599 μs 65.240 μs 0.88 408.49 KB 2.11
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
Intel Xeon 6973P-C 4.09GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 11.0.100
  [Host] : .NET 10.0.15 (10.0.15, 10.0.1526.53008), X64 RyuJIT x86-64-v4

Job=InProcess  Toolchain=InProcessEmitToolchain  InvocationCount=4096  
IterationCount=15  LaunchCount=1  UnrollFactor=1  
WarmupCount=10  

FileInfoBenchmarks
Inspect Mean Error StdDev Ratio Allocated Alloc Ratio
Testably 2.837 μs 0.1652 μs 0.1545 μs 1.00 1.69 KB 1.00
SystemIOAbstractions 1.824 μs 0.0434 μs 0.0363 μs 0.64 2.55 KB 1.51
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
AMD EPYC 7763 3.24GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 11.0.100
  [Host] : .NET 10.0.15 (10.0.15, 10.0.1526.53008), X64 RyuJIT x86-64-v3

Job=InProcess  Toolchain=InProcessEmitToolchain  InvocationCount=65536  
IterationCount=15  LaunchCount=1  UnrollFactor=1  
WarmupCount=10  

FileStreamBenchmarks
Chunks Mean Error StdDev Ratio Allocated Alloc Ratio
Testably 38.35 μs 6.462 μs 6.045 μs 1.02 201.67 KB 1.00
SystemIOAbstractions 64.53 μs 0.812 μs 0.760 μs 1.72 326.67 KB 1.62
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
Intel Xeon 6975P-C 2.70GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 11.0.100
  [Host] : .NET 10.0.15 (10.0.15, 10.0.1526.53008), X64 RyuJIT x86-64-v4

Job=InProcess  Toolchain=InProcessEmitToolchain  InvocationCount=2048  
IterationCount=15  LaunchCount=1  UnrollFactor=1  
WarmupCount=10  

DirectoryTreeBenchmarks
MoveTree Mean Error StdDev Ratio Allocated Alloc Ratio
Testably 278.62 μs 10.443 μs 9.257 μs 1.00 136.05 KB 1.00
SystemIOAbstractions 62.42 μs 0.890 μs 0.833 μs 0.22 106.62 KB 0.78
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
AMD EPYC 7763 3.24GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 11.0.100
  [Host] : .NET 10.0.15 (10.0.15, 10.0.1526.53008), X64 RyuJIT x86-64-v3

Job=InProcess  Toolchain=InProcessEmitToolchain  InvocationCount=512  
IterationCount=15  LaunchCount=1  UnrollFactor=1  
WarmupCount=10  

Enumeration10Benchmarks
Enumerate N Pattern Mean Error StdDev Ratio Allocated Alloc Ratio
Testably 10 ***** 4.837 μs 0.0935 μs 0.0781 μs 1.00 4.86 KB 1.00
SystemIOAbstractions 10 * 4.040 μs 0.0236 μs 0.0209 μs 0.84 3.93 KB 0.81
Testably 10 *.txt 4.780 μs 0.0381 μs 0.0338 μs 1.00 4.55 KB 1.00
SystemIOAbstractions 10 *.txt 6.659 μs 0.0195 μs 0.0173 μs 1.39 4.24 KB 0.93
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
AMD EPYC 9V74 3.69GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 11.0.100
  [Host] : .NET 10.0.15 (10.0.15, 10.0.1526.53008), X64 RyuJIT x86-64-v4

Job=InProcess  Toolchain=InProcessEmitToolchain  InvocationCount=16384  
IterationCount=15  LaunchCount=1  UnrollFactor=1  
WarmupCount=10  

Enumeration1000Benchmarks
Enumerate N Pattern Mean Error StdDev Ratio Allocated Alloc Ratio
Testably 1000 ***** 847.2 μs 2.04 μs 1.60 μs 1.00 308.18 KB 1.00
SystemIOAbstractions 1000 * 253.6 μs 1.40 μs 1.17 μs 0.30 70.42 KB 0.23
Testably 1000 *.txt 862.3 μs 1.50 μs 1.25 μs 1.00 273.42 KB 1.00
SystemIOAbstractions 1000 *.txt 528.1 μs 1.37 μs 1.21 μs 0.61 66.87 KB 0.24
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
INTEL XEON PLATINUM 8573C 3.00GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 11.0.100
  [Host] : .NET 10.0.15 (10.0.15, 10.0.1526.53008), X64 RyuJIT x86-64-v4

Job=InProcess  Toolchain=InProcessEmitToolchain  InvocationCount=512  
IterationCount=15  LaunchCount=1  UnrollFactor=1  
WarmupCount=10  

github-actions Bot added a commit that referenced this pull request Nov 29, 2026
…without creating a `DirectoryInfo` (#1272) by Valentin Breuß
github-actions Bot added a commit that referenced this pull request Nov 29, 2026
…without creating a `DirectoryInfo` (#1272) by Valentin Breuß
@github-actions

Copy link
Copy Markdown

This is addressed in release v8.1.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant