Skip to content

Instantly share code, notes, and snippets.

View antonfirsov's full-sized avatar

Anton Firszov antonfirsov

View GitHub Profile
using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;
using OurVerySecretLib.MathF.LinearAlgebra;
using System.Globalization;
using M = System.Math;
namespace OurVerySecretLib.MathF
{
      Method | InputSize |          Mean |    StdDev | Scaled | Scaled-StdDev |

---------------- |---------- |-------------- |---------- |------- |-------------- | Standard | 16 | 55.6822 ns | 0.1794 ns | 1.00 | 0.00 | Bithack | 16 | 143.3762 ns | 0.4225 ns | 2.57 | 0.01 | BithackBatched | 16 | 110.5777 ns | 7.4833 ns | 1.99 | 0.13 | BatchedPointers | 16 | 49.9270 ns | 0.1580 ns | 0.90 | 0.00 | | | | | | | Standard | 64 | 234.1635 ns | 0.7504 ns | 1.00 | 0.00 | Bithack | 64 | 576.1446 ns | 1.0512 ns | 2.46 | 0.01 | BithackBatched | 64 | 214.5398 ns | 0.4343 ns | 0.92 | 0.00 |

Reisize original:

                  Method |       Mean |    StdErr |    StdDev | Scaled | Scaled-StdDev | Allocated |

---------------------------- |----------- |---------- |---------- |------- |-------------- |---------- | 'System.Drawing Resize' | 55.7482 ms | 0.6225 ms | 2.4109 ms | 1.00 | 0.00 | 512 B | 'ImageSharp Resize' | 28.7155 ms | 0.0552 ms | 0.2138 ms | 0.52 | 0.02 | 187.04 kB | 'ImageSharp Compand Resize' | 58.1706 ms | 0.3284 ms | 1.2717 ms | 1.05 | 0.05 | 186.67 kB |

After:

public interface IClipboardFormat
{
string FormatName { get; }
}
public interface IClipboard
{
void SetData(IClipboardFormat format, object data);
object GetData(IClipboardFormat format);
}
public interface IClipboardFormat
{
string FormatName { get; }
}
public interface IClipboard
{
void SetData(IClipboardFormat format, object data);
object GetData(IClipboardFormat format);
}
public struct Fast2DArray<T>
{
public T[] Data;
public int Width;
public int Height;
public Fast2DArray(T[,] data)
{
this.Height = data.GetLength(0);
namespace ImageSharp
{
using System;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
/// <summary>
/// One interface to rule them all
/// </summary>
@antonfirsov
antonfirsov / BulkPixelsV2.cs
Last active February 16, 2017 23:22
BulkPixelOperations with UnsafeSpan
/// <summary>
/// Since System.Span<T> fails to perform fast (and it will keep being slow for a long time on non-CoreCLR platforms),
/// we need to our own library-wide "semi-safe" solution.
/// It has many advantages over passing void* pointers and/or array+indexer pairs.
/// </summary>
public unsafe struct UnsafeSpan<T> where T : struct
{
public T[] Data { get; }
public int Offset { get; }
// <copyright file="Array2D.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.Benchmarks.General
{
using System;
using BenchmarkDotNet.Attributes;
                          Method | Count |      Mean |    StdErr |    StdDev | Scaled | Scaled-StdDev |

------------------------------------ |------ |---------- |---------- |---------- |------- |-------------- | 'Array access using 2D array' | 10 | 0.6159 ns | 0.0075 ns | 0.0289 ns | 1.00 | 0.00 | 'Array access using a jagged array' | 10 | 1.0694 ns | 0.0153 ns | 0.0591 ns | 1.74 | 0.12 | 'Array access using Fast2DArray' | 10 | 1.0704 ns | 0.0045 ns | 0.0163 ns | 1.74 | 0.08 | 'Array access using 2D array' | 100 | 0.6121 ns | 0.0039 ns | 0.0153 ns | 1.00 | 0.00 | 'Array access using a jagged array' | 100 | 1.0334 ns | 0.0041 ns | 0.0160 ns | 1.69 | 0.05 | 'Array access using Fast2DArray' | 100 | 1.0042 ns | 0.0041 ns | 0.0161 ns | 1.64 | 0.05 | 'Array access using 2D array' | 1000 | 0.6208 ns | 0.0044 ns | 0.0172 ns | 1.00 | 0.00 | 'Array access using a jagged array' | 1000 | 1.030