Skip to content

Instantly share code, notes, and snippets.

View lahma's full-sized avatar

Marko Lahma lahma

View GitHub Profile
#!/bin/bash
# $1 = Azure storage account name
# $2 = Azure storage account key
# $3 = Azure file share name
# $4 = mountpoint path
# For more details refer to https://azure.microsoft.com/en-us/documentation/articles/storage-how-to-use-files-linux/
# update package lists
apt-get -y update
@lahma
lahma / InPerformance.cs
Last active March 27, 2018 13:37
In performance for normal and nullable boolean parameters
using System.Runtime.CompilerServices;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Diagnosers;
namespace Jint.Benchmark
{
[Config(typeof(Config))]
public class InParameterPerformance
{
@lahma
lahma / .NET Core 2.0 vs 2.1.md
Last active April 24, 2018 19:32
Comparing Jint test suite between .NET Core 2.0 and 2.1
BenchmarkDotNet=v0.10.14, OS=Windows 10.0.17134
Intel Core i7-6820HQ CPU 2.70GHz (Skylake), 1 CPU, 8 logical and 4 physical cores
.NET Core SDK=2.1.300-preview2-008533
  [Host]     : .NET Core 2.1.0-preview2-26406-04 (CoreCLR 4.6.26406.07, CoreFX 4.6.26406.04), 64bit RyuJIT
  DefaultJob : .NET Core 2.1.0-preview2-26406-04 (CoreCLR 4.6.26406.07, CoreFX 4.6.26406.04), 64bit RyuJIT

## ArrayBenchmark
| **Diff**|Method|N|Mean|Gen 0|Allocated|
|------- |-------|-------|-------:|-------:|-------:|
| Old |Slice|100|419.5 us|161.1328|660.16 KB|
| **New** | | | **489.6 us (+17%)** | **161.1328 (0%)** | **660.16 KB (0%)** |
| Old |Concat|100|474.5 us|175.7813|720.31 KB|
| **New** | | | **536.4 us (+13%)** | **175.7813 (0%)** | **720.31 KB (0%)** |
| Old |Unshift|100|18,321.2 us|3562.5000|14672.66 KB|
| **New** | | | **21,178.3 us (+16%)** | **3562.5000 (0%)** | **14672.66 KB (0%)** |
@lahma
lahma / ArrayAccessPerformance.cs
Created June 25, 2018 07:46
ArrayAccessPerformance
using System.Runtime.CompilerServices;
using BenchmarkDotNet.Attributes;
namespace Jint.Benchmark
{
public class ArrayAccessBenchmark
{
private class PropertyDescriptor
{
}
@lahma
lahma / IntParseBenchmark.cs
Last active June 29, 2018 08:47
Parsing positive integers faster
using System;
using System.Runtime.CompilerServices;
using BenchmarkDotNet.Attributes;
namespace Jint.Benchmark
{
[MemoryDiagnoser]
public class IntParseBenchmark
{
private const int N = 1_000_000;
public class DocumentTransformer : AbstractTransformerCreationTask<Document>
{
public class Result
{
public string Id { get; set; }
public string[] ExtractedIds { get; set; }
}
public DocumentTransformer()
{
var results = await session.Query<Document>()
.Select(x => new
{
Id = x.Id,
ExtractedIds = x.SomeCollection.ToArray()
})
.ToListAsync();
[MemoryDiagnoser]
public class LinqPitfall
{
private static readonly int[] source = Enumerable.Range(1, 100_000).ToArray();
private readonly HashSet<int> forbidden = new HashSet<int>
{
123, 234, 345, 456, 567, 678, 789, 890, 901, 1000
};
BenchmarkDotNet=v0.11.1, OS=Windows 10.0.17763
Intel Core i7-6820HQ CPU 2.70GHz (Skylake), 1 CPU, 8 logical and 4 physical cores
  [Host]     : .NET Framework 4.7.2 (CLR 4.0.30319.42000), 64bit RyuJIT-v4.7.3190.0
  DefaultJob : .NET Framework 4.7.2 (CLR 4.0.30319.42000), 64bit RyuJIT-v4.7.3190.0

| Method | Mean | Error | StdDev | Scaled | ScaledSD | Gen 0 | Gen 1 | Gen 2 | Allocated |