Skip to content

Instantly share code, notes, and snippets.

View adamsitnik's full-sized avatar

Adam Sitnik adamsitnik

View GitHub Profile
@adamsitnik
adamsitnik / x86JIT_break_VS_return_false
Last active January 9, 2016 15:53
x86 JIT: break; produces jne to loops end, when return false gives je to next comparison. My guess is that the number of jumps taken hurt performance by impairing the instruction pipeline.
x86 version with break;
if (*((void**)firstPointer + 0) != *((void**)secondPointer + 0)) break;
010B3577 mov eax,dword ptr [ebp-10h]
{
if (*((void**)firstPointer + 0) != *((void**)secondPointer + 0)) break;
010B357A mov eax,dword ptr [eax]
010B357C mov edx,dword ptr [ebp-14h]
010B357F cmp eax,dword ptr [edx]
010B3581 jne 010B360F
@adamsitnik
adamsitnik / justAnIdea
Created February 3, 2016 11:10
benchmarkconfiguration
[Config(jit: JitVersion.Legacy)]
[Config(framework: Framework.V35 | Framework.V45)]
public class SampleBenchmark
{
}
[Flags]
public enum JitVersion
{
@adamsitnik
adamsitnik / CopiesBenchmark-report-default.md
Created March 18, 2016 21:22
CopiesBenchmark results for tuned BenchmarkDotNet

BenchmarkDotNet-Dev=v0.9.3.0+ OS=Microsoft Windows NT 6.2.9200.0 Processor=Intel(R) Xeon(R) CPU E5-2620 0 @ 2.00GHz, ProcessorCount=8 Frequency=10000000 ticks, Resolution=100.0000 ns, Timer=HPET HostCLR=MS.NET 4.0.30319.42000, Arch=32-bit RELEASE JitModules=clrjit-v4.6.1055.0

Type=CopiesBenchmark Mode=Throughput LaunchCount=1
WarmupCount=1 TargetCount=5

@adamsitnik
adamsitnik / Program.cs
Created December 28, 2016 09:13
memory monitoring
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
namespace TotalMemory
{
public class Program
@adamsitnik
adamsitnik / gist:4bddece1b672964c0769751dd4f73323
Created February 28, 2017 07:05
dotnet pack -v detailed
Microsoft (R) Build Engine version 15.2.2.21747
Copyright (C) Microsoft Corporation. All rights reserved.
Build started 2/28/2017 8:02:02 AM.
1>Project "C:\Projects\BenchmarkDotNet\src\BenchmarkDotNet.Core\BenchmarkDotNet.Core.csproj" on node 1 (pack target(s)).
1>Building with tools version "15.0".
Project file contains ToolsVersion="". This toolset may be unknown or missing, in which case you may be able to resolve this by installing the appropriate version of MSBuild, or the build may have been forced to a particular ToolsVersion for policy reasons. Treating the project as if it had ToolsVersion="15.0". For more information, please see http://go.microsoft.com/fwlink/?LinkId=293424.
1>Target "_IntermediatePack" in file "C:\Program Files\dotnet\sdk\2.0.0-alpha-004853\Sdks\NuGet.Build.Tasks.Pack\buildCrossTargeting\NuGet.Build.Tasks.Pack.targets" from project "C:\Projects\BenchmarkDotNet\src\BenchmarkDotNet.Core\BenchmarkDotNet.Core.csproj" (target "Pack" depends on it):
1>Done bui
@adamsitnik
adamsitnik / gist:cd45f641abeb79f14d9828aef12bcd2a
Created February 28, 2017 09:32
dotnet build .\src\BenchmarkDotNet.Core\BenchmarkDotNet.Core.csproj -c Release -v detailed
Microsoft (R) Build Engine version 15.2.2.21747
Copyright (C) Microsoft Corporation. All rights reserved.
Build started 2/28/2017 10:31:00 AM.
1>Project "C:\Projects\BenchmarkDotNet\src\BenchmarkDotNet.Core\BenchmarkDotNet.Core.csproj" on node 1 (Build target(s)).
1>Building with tools version "15.0".
Project file contains ToolsVersion="". This toolset may be unknown or missing, in which case you may be able to resolve this by installing the appropriate version of MSBuild, or the build may have been forced to a particular ToolsVersion for policy reasons. Treating the project as if it had ToolsVersion="15.0". For more information, please see http://go.microsoft.com/fwlink/?LinkId=293424.
1>Target "_SetBuildInnerTarget" in file "C:\Program Files\dotnet\sdk\2.0.0-alpha-004853\Microsoft.Common.CrossTargeting.targets" from project "C:\Projects\BenchmarkDotNet\src\BenchmarkDotNet.Core\BenchmarkDotNet.Core.csproj" (target "Build" depends on it):
1>Done building target "_SetBuildInnerTarge
@adamsitnik
adamsitnik / Program.cs
Created June 16, 2017 14:43
hardwareCountersForTwoDifferentRuntimes
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Diagnosers;
using BenchmarkDotNet.Environments;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Running;
using BenchmarkDotNet.Toolchains.CsProj;
using System;
using System.Linq;
[RyuJitX64Job, LegacyJitX86Job]
public class CopyingValueTypes
{
class ReferenceType1Field { int X; }
class ReferenceType2Fields { int X, Y; }
class ReferenceType3Fields { int X, Y, Z; }
struct ValueType1Field { int X; }
struct ValueType2Fields { int X, Y; }
struct ValueType3Fields { int X, Y, Z; }
@adamsitnik
adamsitnik / disasm.html
Created August 16, 2017 14:59
Devirtualization
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='utf-8' />
<title>DisassemblyDiagnoser Output Jit_Devirtualization</title>
<style type="text/css">
table { border-collapse: collapse; display: block; width: 100%; overflow: auto; }
td, th { padding: 6px 13px; border: 1px solid #ddd; }
tr { background-color: #fff; border-top: 1px solid #ccc; }
GlobalSetup();
for (int s = 0; s < stagesCount; s++)
for (int it = 0; it < iterationsCount; it++)
{
IterationSetup();
for (int inv = 0; inv < invocationsCount; inv++)
Benchmark();