Skip to content

Instantly share code, notes, and snippets.

/*
BenchmarkDotNet=v0.12.0, OS=Windows 10.0.18363
Intel Core i7-6950X CPU 3.00GHz (Skylake), 1 CPU, 20 logical and 10 physical cores
[Host] : .NET Framework 4.8 (4.8.4121.0), X86 LegacyJIT
DefaultJob : .NET Framework 4.8 (4.8.4121.0), X86 LegacyJIT
| Method | Mean | Error | StdDev |
|-------------- |---------:|---------:|---------:|
| LockTryGetSet | 28.42 ns | 0.006 ns | 0.006 ns |
@ermau
ermau / keybase.md
Last active October 12, 2017 03:18

Keybase proof

I hereby claim:

  • I am ermau on github.
  • I am ermau (https://keybase.io/ermau) on keybase.
  • I have a public key whose fingerprint is B032 F123 E947 6FD4 F306 7228 F0F9 C8F1 4AAB 745A

To claim this, I am signing this object:

/*
DynamicMethod creation: 0.0053597000ms
LINQ expressions creation: 0.1050939000ms
DynamicMethod invocation: 0.0000474000ms
Expression invocation: 0.0000450000ms
MethodInfo invocation: 0.0002190000ms
Calls to reach even with MethodInfo:
DynamicMethod: 24.6899543379
@ermau
ermau / gist:1552267
Created January 2, 2012 21:50
Get a list of names, phones and emails on Android with Xamarin.Mobile
TextView t = FindViewById<TextView> (Resource.Id.status);
StringBuilder builder = new StringBuilder();
var book = new AddressBook (this);
book.PreferContactAggregation = true;
foreach (Contact c in book.Where (c => c.FirstName == "Eric"))
{
builder.AppendLine (c.DisplayName);
@ermau
ermau / gist:1552248
Created January 2, 2012 21:44
Get a list of names, phones and emails on Android
TextView t = FindViewById<TextView> (Resource.Id.status);
StringBuilder builder = new StringBuilder();
ICursor ncursor = null;
try
{
ncursor = ContentResolver.Query (ContactsContract.Data.ContentUri, new[] { ContactsContract.DataColumns.Mimetype, ContactsContract.ContactsColumns.LookupKey, ContactsContract.ContactsColumns.DisplayName },
ContactsContract.DataColumns.Mimetype + "=? AND " + ContactsContract.CommonDataKinds.StructuredName.GivenName + "=?",
new[] { ContactsContract.CommonDataKinds.StructuredName.ContentItemType, "Eric" }, null);
/*
Times for 10,000 iterations averaged over 300 tests in milliseconds
Test 2 bytes 4 bytes 6 bytes 8 bytes
Array 0.739094 0.771695 0.774858 0.759280
Buffer 0.644463 0.634443 0.646658 0.650585
Unsafe value 0.504277 0.615360 0.742236 0.851658
Hybrid UnsafeValue 0.609504 0.476190 0.558644 0.236927
Hybrid BlockCopy 0.608247 0.767905 0.883720 0.251436
Hybrid PtrSafe 0.584011 0.487495 0.678595 0.249857
/* This code is free software. It comes without any warranty, to
* the extent permitted by applicable law. You can redistribute it
* and/or modify it under the terms of the Do What The Fuck You Want
* To Public License, Version 2, as published by Sam Hocevar. See
* http://sam.zoy.org/wtfpl/COPYING for more details. */
public class SilverlightAudioCaptureDeviceProvider
{
public SilverlightAudioCaptureDeviceProvider()
{