Skip to content

Instantly share code, notes, and snippets.

View davidfowl's full-sized avatar

David Fowler davidfowl

View GitHub Profile
This file has been truncated, but you can view the full file.
[12:04:42.659] Using worker Wrk
[12:04:42.754] Running session '92c5e28c8dec4dab902cd1ff12ccaf9d' with description ''
[12:04:42.754] Starting scenario ResponseCachingPlaintextCachedDelete on benchmark server...
[12:04:42.837] Fetching job: http://10.195.201.248:5001/jobs/31
[12:04:42.917] Job submitted, waiting...
[12:05:16.053] Starting scenario ResponseCachingPlaintextCachedDelete on benchmark client...
[12:05:16.488] Client Job ready: http://10.195.202.5:5002/jobs/1
[12:05:18.654] Scenario ResponseCachingPlaintextCachedDelete completed on benchmark client
[12:05:18.655] Deleting scenario ResponseCachingPlaintextCachedDelete on benchmark client...
RequestsPerSecond: 1,334
@davidfowl
davidfowl / MemoryLeak.cs
Last active January 19, 2019 15:01
Leaking tasks
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace ConsoleApp19
{
class Program
{
private static Dictionary<string, Task<string>> _cache = new Dictionary<string, Task<string>>();
@davidfowl
davidfowl / Multitenancy.cs
Last active May 15, 2023 05:30
Multitenancy
using System;
using System.Collections.Generic;
using System.Threading;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
/*
- Don't need to support different services per tenant.
- Tenant services lifetime outlasts the request.
using System;
using System.Collections.Generic;
using System.Threading;
namespace TimersAreWeird
{
public class Program
{
public static void Main(string[] args)
{

ReadOnlySequence.Slice + Span

             Method |          Input | HubProtocol |      Mean |     Error |    StdDev |      Op/s |  Gen 0 | Allocated |
------------------ |--------------- |------------ |----------:|----------:|----------:|----------:|-------:|----------:|
 ReadSingleMessage |   FewArguments |        Json |  2.459 us | 0.0491 us | 0.1295 us | 406,692.8 | 0.0305 |     960 B |
 ReadSingleMessage | LargeArguments |        Json | 90.188 us | 2.1015 us | 6.0296 us |  11,087.9 | 1.9531 |   58840 B |
 ReadSingleMessage |  ManyArguments |        Json |  4.403 us | 0.0922 us | 0.2063 us | 227,115.5 | 0.0458 |    1504 B |
 ReadSingleMessage |    NoArguments |        Json |  1.194 us | 0.0249 us | 0.0449 us | 837,771.3 | 0.0172 |     584 B |
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Net.Http;
using System.Threading;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
namespace header_propagation
using System;
using System.Buffers;
using System.Buffers.Text;
using System.Collections.Generic;
using System.IO;
using System.IO.Pipelines;
using System.Text;
using System.Threading.Tasks;
namespace perf_demo
@davidfowl
davidfowl / AUsage.cs
Last active December 26, 2024 23:13
Header propagation HttpClientFactory middleware
public void ConfigureServices(IServiceCollection services)
{
services.AddHttpClient("myclient");
// Global header propagation for any HttpClient that comes from HttpClientFactory
services.AddHeaderPropagation(options =>
{
options.HeaderNames.Add("Correlation-Id");
});
}
@davidfowl
davidfowl / Global.asax.cs
Last active August 12, 2025 17:53
ASP.NET MVC and ServiceCollection sample
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Mvc;
using System.Web.Optimization;
using System.Web.Routing;
using Microsoft.Extensions.DependencyInjection;
using WebApplication16;
using WebApplication16.Controllers;
public class NagleAwaitable : ICriticalNotifyCompletion
{
private readonly ConcurrentQueue<Action> _work = new ConcurrentQueue<Action>();
private readonly TimerAwaitable _timerAwaitable;
private bool _timerResult;
public NagleAwaitable(TimeSpan period)
{
_timerAwaitable = new TimerAwaitable(period, period);