Skip to content

Instantly share code, notes, and snippets.

View itn3000's full-sized avatar
πŸ€”
πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”

Yusuke Ito itn3000

πŸ€”
πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”
View GitHub Profile
using System;
namespace spantest
{
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using BenchmarkDotNet.Attributes.Jobs;
using BenchmarkDotNet.Diagnosers;
using System.Linq;
[MemoryDiagnoser]
@itn3000
itn3000 / ByteComparer.cs
Last active August 29, 2017 09:10
byte array comparer(inspired by Messagepack-CSharp and System.Span<T>)
using System;
static class ByteComparer
{
public static bool AreSameSpan(byte[] b1, byte[] b2)
{
var span = new Span<byte>(b1);
var span2 = new Span<byte>(b2);
return span.SequenceEqual(span2);
}
@itn3000
itn3000 / UnsafeFixed.cs
Created August 31, 2017 06:50
fixed expression optimization
using System;
namespace unsafefixedtest
{
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
public class UnsafeFixedBench
{
[Params(1000)]
public int LoopNum;
@itn3000
itn3000 / MiniProfilerBench.cs
Last active September 26, 2017 09:24
MiniProfiler overhead
using System;
namespace miniprofilerclitest
{
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using BenchmarkDotNet.Attributes.Jobs;
using StackExchange.Profiling;
using StackExchange.Profiling.Storage;
using System.Collections.Generic;
@itn3000
itn3000 / jilutf8jsontest.cs
Created September 28, 2017 01:14
Utf8Json vs Jil
using System;
namespace jilutf8jsontest
{
using Utf8Json;
using Jil;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using BenchmarkDotNet.Attributes.Jobs;
public struct MyModel
@itn3000
itn3000 / UnicodeUtility.BenchmarkCode.cs
Last active October 6, 2017 15:25
benchmark of utf8 decoding
using System;
namespace msgpack.utf8bench
{
using System.Linq;
using System.Text;
using MessagePack.Internal;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using BenchmarkDotNet.Diagnosers;
echo arg1 is %1
echo arg2 is %2
@itn3000
itn3000 / ForeachWithIndex.cs
Created October 18, 2017 14:14
foreach with index with valuetuple
using System;
using System.Linq;
static class Test
{
public static void ForeachWithIndex()
{
var strs = new string[] { "a", "b", "c" };
foreach (var (str, idx) in strs.Select((s, i) => (s, i)))
{
Console.WriteLine($"{str},{idx}");
@itn3000
itn3000 / DataTableStackOverflow.cs
Created October 19, 2017 03:05
StackOverflowException on DataTable.Select(too many conditions)
using System;
namespace datatabletest
{
using System.Data;
using System.Linq;
class Program
{
static void Main(string[] args)
{
@itn3000
itn3000 / UsingHttpClientConcurrentCore.cs
Last active January 16, 2018 23:56
concurrent httpclient netframework
using System;
namespace multithreadedhttpclient_core
{
using System.Threading;
using System.Net;
using System.Net.Http;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Threading.Tasks;