1
- using System ;
2
- using System . IO ;
3
- using System . IO . Abstractions . Benchmarks . Support ;
1
+ using System . IO . Abstractions . Benchmarks . Support ;
4
2
using BenchmarkDotNet . Attributes ;
5
3
using BenchmarkDotNet . Order ;
6
4
@@ -13,36 +11,34 @@ namespace System.IO.Abstractions.Benchmarks;
13
11
[ RankColumn ]
14
12
public class FileSystemAbstractionBenchmarks
15
13
{
16
- #region Members
17
14
/// <summary>
18
15
/// FileSupport type to avoid counting object initialisation on the benchmark
19
16
/// </summary>
20
- private FileSupport _fileSupport ;
21
- private DirectorySupport _directorySupport ;
22
- #endregion
17
+ private readonly FileSupport _fileSupport ;
18
+ private readonly DirectorySupport _directorySupport ;
19
+
20
+ private readonly string _path = Environment . GetFolderPath ( Environment . SpecialFolder . UserProfile ) ;
23
21
24
- #region CTOR's
25
22
public FileSystemAbstractionBenchmarks ( )
26
23
{
27
24
// Initialize file support
28
25
_fileSupport = new FileSupport ( ) ;
29
26
_directorySupport = new DirectorySupport ( ) ;
30
27
}
31
- #endregion
32
28
33
29
#region File IsFile
34
30
[ Benchmark ]
35
- public void FileExists_DotNet ( ) => FileSupportStatic . IsFile ( Environment . GetFolderPath ( Environment . SpecialFolder . UserProfile ) ) ;
31
+ public void FileExists_DotNet ( ) => FileSupportStatic . IsFile ( _path ) ;
36
32
37
33
[ Benchmark ]
38
- public void FileExists_Abstraction ( ) => _fileSupport . IsFile ( Environment . GetFolderPath ( Environment . SpecialFolder . UserProfile ) ) ;
34
+ public void FileExists_Abstraction ( ) => _fileSupport . IsFile ( _path ) ;
39
35
#endregion
40
36
41
37
#region Directory Exists
42
38
[ Benchmark ]
43
- public void DirectoryExists_DotNet ( ) => DirectorySupportStatic . Exists ( Environment . GetFolderPath ( Environment . SpecialFolder . UserProfile ) ) ;
39
+ public void DirectoryExists_DotNet ( ) => DirectorySupportStatic . Exists ( _path ) ;
44
40
45
41
[ Benchmark ]
46
- public void DirectoryExists_Abstraction ( ) => _directorySupport . Exists ( Environment . GetFolderPath ( Environment . SpecialFolder . UserProfile ) ) ;
42
+ public void DirectoryExists_Abstraction ( ) => _directorySupport . Exists ( _path ) ;
47
43
#endregion
48
44
}
0 commit comments