View benchmark.cs
public class Hashset | |
{ | |
[Benchmark] | |
public void HashSet_Int32() | |
{ | |
var hashset = new HashSet<int>(); | |
for (int i = 0; i < 1000; i++) | |
{ | |
hashset.Add(i); | |
} |
View Range.cs
// https://www.meziantou.net/how-to-use-csharp-8-indices-and-ranges-in-dotnet-standard-2-0-and-dotn.htm |
View NullableAttributes.cs
#pragma warning disable MA0048 // File name must match type name | |
#define INTERNAL_NULLABLE_ATTRIBUTES | |
#if NETSTANDARD2_0 || NETCOREAPP2_0 || NETCOREAPP2_1 || NETCOREAPP2_2 || NET45 || NET451 || NET452 || NET46 || NET461 || NET462 || NET47 || NET471 || NET472 || NET48 | |
// https://github.com/dotnet/corefx/blob/48363ac826ccf66fbe31a5dcb1dc2aab9a7dd768/src/Common/src/CoreLib/System/Diagnostics/CodeAnalysis/NullableAttributes.cs | |
// Licensed to the .NET Foundation under one or more agreements. | |
// The .NET Foundation licenses this file to you under the MIT license. | |
// See the LICENSE file in the project root for more information. |
View program.cs
internal static class Program | |
{ | |
private static void Main() | |
{ | |
BenchmarkRunner.Run<Remove>(); | |
} | |
} | |
[CoreJob] | |
[MemoryDiagnoser] |
View benchmark.cs
[Benchmark] | |
public string V1() | |
{ | |
return string.Create(13, _id, (buffer, id) => | |
{ | |
var encode32CharsArray = _encode32CharsArray; | |
buffer[0] = encode32CharsArray[(id >> 60) & 31]; | |
buffer[1] = encode32CharsArray[(id >> 55) & 31]; | |
buffer[2] = encode32CharsArray[(id >> 50) & 31]; |
View Results Bounds check assembly.txt
.NET Core 2.2.0 (CoreCLR 4.6.27110.04, CoreFX 4.6.27110.04), 64bit RyuJIT | |
BranchmarkString.Benchmark.V6() | |
return string.Create(13, _id, (buffer, id) => | |
^^^ | |
{ | |
^^^ | |
var encode32CharsArray = _encode32CharsArray; | |
^^^ | |
buffer[12] = encode32CharsArray[id & 31]; | |
^^^ |
View program.cs
static void Main(string[] args) | |
{ | |
var xsl = XDocument.Parse(@"<xsl:stylesheet version=""1.0"" | |
xmlns:xsl=""http://www.w3.org/1999/XSL/Transform"" | |
xmlns:msxsl=""urn:schemas-microsoft-com:xslt"" | |
xmlns:user=""http://dummy/ns""> | |
<msxsl:script language=""C#"" implements-prefix=""user""> | |
<![CDATA[ | |
public string Code() | |
{ |
View main.cs
private void OnPaste(object sender, DataObjectPastingEventArgs e) | |
{ | |
HandleDataObject(e.DataObject); | |
e.Handled = true; | |
} | |
private void HandleDataObject(IDataObject data) | |
{ | |
if (data == null) throw new ArgumentNullException(nameof(data)); |
View RemoteDataCache.cs
using System; | |
using System.Threading; | |
using System.Threading.Tasks; | |
namespace ClassLibrary1 | |
{ | |
public abstract class RemoteDataCache<T> : IDisposable | |
{ | |
private readonly SemaphoreSlim _semaphoreSlim = new SemaphoreSlim(1, 1); | |
private CacheValue<T> _value; |
View program.cs
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
BenchmarkRunner.Run<StringBenchmark>(); | |
} | |
} | |
[OrderProvider(SummaryOrderPolicy.FastestToSlowest)] | |
[CoreJob] |
NewerOlder