// Inspired by https://twitter.com/Nick_Craver/status/702693060472414208
public class Framework_Interpolated_vs_ToString
{
private long counter = 0;
[Setup]
public void Setup()
{
counter = 0;
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
// From https://twitter.com/aarnott/status/701653964823990273 | |
public class Framework_Guid | |
{ | |
[Benchmark(Baseline = true)] | |
public Guid CtorWithHexValues() | |
{ | |
// creates a Guid that corresponds to "12345678-000b-000c-0001-020304050607". | |
return new Guid(0x12345678, 0xb, 0xc, 0, 1, 2, 3, 4, 5, 6, 7); | |
} |
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
// ***** BenchmarkRunner: Start ***** | |
// Found benchmarks: | |
// IntroBasic_SleepWithDescription | |
// IntroBasic_Sleep | |
// ************************** | |
// Benchmark: IntroBasic_SleepWithDescription | |
// *** Generate *** | |
// Result = Success | |
// DirectoryPath = C:\__GitHub__\BenchmarkDotNet\BenchmarkDotNet.Samples\bin\Release\IntroBasic_SleepWithDescription |
From this Benchmark code:
[Benchmark]
public Dictionary<string, string> DictionaryEnumeration()
{
// Doesn't allocate
foreach (var item in dict)
{
;
}
- The command letter can be eliminated on subsequent commands if the same command is used multiple times in a row (e.g., you can drop the second "L" in "M 100 200 L 200 100 L -100 -200" and use "M 100 200 L 200 100 -100 -200" instead).
<svg version="1.1" baseProfile="full" width="500" height="50" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="none">
<line x1="0" y1="50" x2="500" y2="50" stroke="#f6f6f6" stroke-width="1" />
<g fill="#008cba" stroke="none">
<path d="M0 50 L0 41.7 L1 41.5 L2 42.2 L3 43.5 L4 44.3 L5 44.7 L6 45.2 L7 43.5 L8 44.3 L9 42.7 L10 42.3 L11 43.5 L12 44.5 L13 44.3 L14 44.3 L15 42.7 L16 43.0 L17 41.3 L18 40.8 L19 40.3 L20 41.8 L21 41.3 L22 42.8 L23 44.0 L24 42.7 L25 43.2 L26 43.8 L27 44.5 L28 43.2 L29 42.8 L30 44.0 L31 44.2 L32 43.3 L33 42.0 L34 42.5 L35 41.0 L36 39.5 L37 40.0 L38 40.5 L39 41.0 L40 40.7 L41 41.2 L42 41.7 L43 40.0 L44 41.0 L45 41.7 L46 41.0 L47 4
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; | |
using BenchmarkDotNet.Attributes; | |
using BenchmarkDotNet.Running; | |
using System.Collections.Generic; | |
using System.Collections.Immutable; | |
namespace ImmutabilityBenchmark | |
{ | |
//[Config(processCount: 1, warmupIterationCount: 1, targetIterationCount: 1)] | |
public class BenchmarkProgram |
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 interface IObjectPool<T> | |
{ | |
T Rent(); | |
void Return(T obj); | |
} | |
public interface IResetable | |
{ | |
void Reset(); | |
} |
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
module BenchmarkSpec | |
open BenchmarkDotNet | |
open NUnit.Framework | |
open FsUnit | |
open BenchmarkDotNet.Tasks | |
open System.Threading | |
type File = | |
{ Name : string |
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
<Query Kind="Program"> | |
<NuGetReference>Octokit</NuGetReference> | |
<NuGetReference>Octokit.Reactive</NuGetReference> | |
<NuGetReference>Rx-Main</NuGetReference> | |
<Namespace>Octokit</Namespace> | |
<Namespace>System.Linq</Namespace> | |
<Namespace>System.Reactive.Linq</Namespace> | |
<Namespace>System.Threading.Tasks</Namespace> | |
</Query> |
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
[BenchmarkTask(processCount: 1)] | |
public unsafe class StringBuilderEfficientAppend | |
{ | |
[Params(1, 5, 10, 20, 50)] | |
public int StringLength; | |
private byte[] UTF8Bytes; | |
private byte* bytes; | |
private IntPtr unmanagedPointer; |