(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
Latency Comparison Numbers (~2012) | |
---------------------------------- | |
L1 cache reference 0.5 ns | |
Branch mispredict 5 ns | |
L2 cache reference 7 ns 14x L1 cache | |
Mutex lock/unlock 25 ns | |
Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
Compress 1K bytes with Zippy 3,000 ns 3 us | |
Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
Write-Host "Installing .NET MicroFramework 4.3 ..." | |
$msiPath = "$($env:USERPROFILE)\MicroFrameworkSDK43.MSI" | |
(New-Object Net.WebClient).DownloadFile('http://download-codeplex.sec.s-msft.com/Download/Release?ProjectName=netmf&DownloadId=1423116&FileTime=130667921437670000&Build=21031', $msiPath) | |
cmd /c start /wait msiexec /i $msiPath /quiet | |
Write-Host "Installed" -ForegroundColor green | |
Write-Host "Installing .NET MicroFramework 4.4 ..." | |
$msiPath = "$($env:USERPROFILE)\MicroFrameworkSDK44.MSI" | |
(New-Object Net.WebClient).DownloadFile('https://github.com/NETMF/netmf-interpreter/releases/download/v4.4-RTW-20-Oct-2015/MicroFrameworkSDK.MSI', $msiPath) | |
cmd /c start /wait msiexec /i $msiPath /quiet |
namespace Analogy | |
{ | |
/// <summary> | |
/// This example shows that a library that needs access to target .NET Standard 1.3 | |
/// can only access APIs available in that .NET Standard. Even though similar the APIs exist on .NET | |
/// Framework 4.5, it implements a version of .NET Standard that isn't compatible with the library. | |
/// </summary>INetCoreApp10 | |
class Example1 | |
{ | |
public void Net45Application(INetFramework45 platform) |
Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.
public static class IQueryableExtensions | |
{ | |
private static readonly TypeInfo QueryCompilerTypeInfo = typeof(QueryCompiler).GetTypeInfo(); | |
private static readonly FieldInfo QueryCompilerField = typeof(EntityQueryProvider).GetTypeInfo().DeclaredFields.First(x => x.Name == "_queryCompiler"); | |
private static readonly PropertyInfo NodeTypeProviderField = QueryCompilerTypeInfo.DeclaredProperties.Single(x => x.Name == "NodeTypeProvider"); | |
private static readonly MethodInfo CreateQueryParserMethod = QueryCompilerTypeInfo.DeclaredMethods.First(x => x.Name == "CreateQueryParser"); |
namespace InMemoreCompilation | |
{ | |
public static class CodeGenerator | |
{ | |
public static string GenerateCalculator() | |
{ | |
var calculator = @"namespace Calculator | |
{ | |
public class Calculator | |
{ |
// TUPLE MICRO-BENCHMARKS, based on https://www.dotnetperls.com/tuple-keyvaluepair | |
// | |
// Tuples are generally fastest. | |
// ValueTuple is fastest in the particular case of GetHashCode. | |
// KeyValuePair is always worst. | |
// | |
// | |
// RAW RESULTS | |
// Numbers in milliseconds (lower is better) | |
// |
public struct AsciiString : IEquatable<AsciiString> | |
{ | |
private readonly byte[] _data; | |
public AsciiString(byte[] bytes) => _data = bytes; | |
public AsciiString(string s) => _data = Encoding.ASCII.GetBytes(s); | |
public int Length => _data.Length; |
// based on https://github.com/dotnet/corefx/blob/389d7ee/src/System.Memory/tests/Memory/CustomMemoryForTest.cs | |
unsafe class HGlobalMemory : OwnedMemory<byte> | |
{ | |
private bool _disposed; | |
private int _referenceCount; | |
private byte* _buffer; | |
private int _length; | |
public HGlobalMemory(int length) | |
{ |