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
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) |
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
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); |
var nagle = new NagleTimer(); | |
while (true) | |
{ | |
var result = await reader.ReadAsync(); | |
var buffer = result.Buffer; | |
try | |
{ | |
if (!buffer.IsEmpty) |
{ | |
"Logging": { | |
"Default": { | |
"LogLevel": { | |
"Microsoft.AspNetCore": "Critical", | |
"System": "Warning" | |
} | |
}, | |
"DebugLogger": { // do these override "Default" section above? | |
"LogLevel": { |
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] |