Skip to content

Instantly share code, notes, and snippets.

Avatar

Brennan BrennanConroy

View GitHub Profile
View ConsoleApp.cs
using System;
using System.Collections.Generic;
using System.Net.WebSockets;
using System.Threading.Tasks;
namespace ConsoleApp
{
internal class Program
{
public static async Task Main(string[] args)
@BrennanConroy
BrennanConroy / allocations.md
Last active May 28, 2019
Hidden allocations of .NET
View allocations.md

Intro: always measure first and test after

Start simple:

  • class vs. struct

  • pre-alloc container sizes if possible

  • string.Substring(1, 10);

  • stackalloc byte[]/Span

  • for loops vs. foreach loops

View api.cpp
class transport
{
void start(std::string url, transfer_format format, std::function<void(std::exception_ptr)> callback);
void stop(std::function<void(std::exception_ptr)> callback);
void on_close(std::function<void(std::exception_ptr)>);
void send(std::string payload, std::function<void(std::exception_ptr)> callback);
void on_receive(std::function<void(std::string, std::exception_ptr)> callback);
View nagle
var nagle = new NagleTimer();
while (true)
{
var result = await reader.ReadAsync();
var buffer = result.Buffer;
try
{
if (!buffer.IsEmpty)
View gist:fc3210dbf59a10f5c4ee34df9706e682
{
"Logging": {
"Default": {
"LogLevel": {
"Microsoft.AspNetCore": "Critical",
"System": "Warning"
}
},
"DebugLogger": { // do these override "Default" section above?
"LogLevel": {
View dotnet_hang_csc.txt
Sampling process 91708 for 3 seconds with 1 millisecond of run time between samples
Sampling completed, processing symbols...
Analysis of sampling dotnet (pid 91708) every 1 millisecond
Process: dotnet [91708]
Path: /Users/asplab/.dotnet/dotnet
Load Address: 0x1007c3000
Identifier: dotnet
Version: 0
Code Type: X86-64
Parent Process: dotnet [91706]