-
Notifications
You must be signed in to change notification settings - Fork 264
Expand file tree
/
Copy pathFileSystemAbstractionBenchmarks.cs
More file actions
44 lines (36 loc) · 1.33 KB
/
FileSystemAbstractionBenchmarks.cs
File metadata and controls
44 lines (36 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using System.IO.Abstractions.Benchmarks.Support;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Order;
namespace System.IO.Abstractions.Benchmarks;
//[SimpleJob(launchCount: 3, warmupCount: 10, targetCount: 30)]
[RPlotExporter]
[MemoryDiagnoser]
[Orderer(summaryOrderPolicy: SummaryOrderPolicy.FastestToSlowest)]
[RankColumn]
public class FileSystemAbstractionBenchmarks
{
/// <summary>
/// FileSupport type to avoid counting object initialisation on the benchmark
/// </summary>
private readonly FileSupport _fileSupport;
private readonly DirectorySupport _directorySupport;
private readonly string _path = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
public FileSystemAbstractionBenchmarks()
{
// Initialize file support
_fileSupport = new FileSupport();
_directorySupport = new DirectorySupport();
}
#region File IsFile
[Benchmark]
public void FileExists_DotNet() => FileSupportStatic.IsFile(_path);
[Benchmark]
public void FileExists_Abstraction() => _fileSupport.IsFile(_path);
#endregion
#region Directory Exists
[Benchmark]
public void DirectoryExists_DotNet() => DirectorySupportStatic.Exists(_path);
[Benchmark]
public void DirectoryExists_Abstraction() => _directorySupport.Exists(_path);
#endregion
}