This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using BenchmarkDotNet.Attributes; | |
using BenchmarkDotNet.Running; | |
using System; | |
using System.Runtime.CompilerServices; | |
namespace CoreMkRef | |
{ | |
class Program | |
{ | |
static void Main(string[] args) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using BenchmarkDotNet.Attributes; | |
using BenchmarkDotNet.Reports; | |
using BenchmarkDotNet.Running; | |
using System; | |
using System.Buffers; | |
using System.Runtime.CompilerServices; | |
namespace ConsoleApp10 | |
{ | |
public delegate Span<T> Allocator<T>(int length); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Buffers; | |
using System.Diagnostics; | |
using System.Reflection; | |
using System.Runtime.CompilerServices; | |
using System.Threading; | |
using System.Threading.Tasks; | |
static class PoolingBenchmark | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace System.IO.Enumeration | |
{ | |
public static class FileSystemName | |
{ | |
// Change '*' and '?' to '<', '>', and '"' to match Win32 behavior | |
public static string TranslateWin32Expression(string expression); | |
// This matches '*', '?', '<', '>', and '"' wildcards | |
public static bool MatchesWin32Expression(ReadOnlySpan<char> expression, ReadOnlySpan<char> name, bool ignoreCase = true); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static long CountFileBytes(string directory, bool recursive) | |
{ | |
return (new FileSystemEnumerable<long>( | |
directory, | |
(ref FileSystemEntry entry) => entry.Length, | |
new EnumerationOptions() { RecurseSubdirectories = recursive }) | |
{ | |
ShouldIncludePredicate = (ref FileSystemEntry entry) => !entry.IsDirectory | |
}).Sum(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static int CountFiles(string directory, bool recursive) | |
{ | |
return (new FileSystemEnumerable<int>( | |
directory, | |
(ref FileSystemEntry entry) => 1, | |
new EnumerationOptions() { RecurseSubdirectories = recursive }) | |
{ | |
ShouldIncludePredicate = (ref FileSystemEntry entry) => !entry.IsDirectory | |
}).Count(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static IEnumerable<FileInfo> GetFilesWithExtensions(string directory, | |
bool recursive, params string[] extensions) | |
{ | |
return new FileSystemEnumerable<FileInfo>( | |
directory, | |
(ref FileSystemEntry entry) => (FileInfo)entry.ToFileSystemInfo(), | |
new EnumerationOptions() { RecurseSubdirectories = recursive }) | |
{ | |
ShouldIncludePredicate = (ref FileSystemEntry entry) => | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IEnumerable<string> fileNames = | |
new FileSystemEnumerable<string>( | |
@"C:\test", | |
(ref FileSystemEntry entry) => entry.FileName.ToString()) | |
{ | |
ShouldIncludePredicate = (ref FileSystemEntry entry) => !entry.IsDirectory | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IEnumerable<string> fileAndDirectoryNames = | |
new FileSystemEnumerable<string>(@"C:\", (ref FileSystemEntry entry) => entry.FileName.ToString()); |
NewerOlder