-
Notifications
You must be signed in to change notification settings - Fork 264
Expand file tree
/
Copy pathFileSystemAbstractionBenchmarks.cs
More file actions
48 lines (41 loc) · 1.54 KB
/
FileSystemAbstractionBenchmarks.cs
File metadata and controls
48 lines (41 loc) · 1.54 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
45
46
47
48
using System;
using System.IO;
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
{
#region Members
/// <summary>
/// FileSupport type to avoid counting object initialisation on the benchmark
/// </summary>
private FileSupport _fileSupport;
private DirectorySupport _directorySupport;
#endregion
#region CTOR's
public FileSystemAbstractionBenchmarks()
{
// Initialize file support
_fileSupport = new FileSupport();
_directorySupport = new DirectorySupport();
}
#endregion
#region File IsFile
[Benchmark]
public void FileExists_DotNet() => FileSupportStatic.IsFile(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile));
[Benchmark]
public void FileExists_Abstraction() => _fileSupport.IsFile(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile));
#endregion
#region Directory Exists
[Benchmark]
public void DirectoryExists_DotNet() => DirectorySupportStatic.Exists(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile));
[Benchmark]
public void DirectoryExists_Abstraction() => _directorySupport.Exists(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile));
#endregion
}