The Problem That Drove Me Crazy
I was building a CLI tool for Package Script Writer that calls various APIs to fetch Umbraco packages and generate installation scripts. Everything worked perfectly in the browser, API calls completed in under a second. But when I ran the same code from my console application, every single API call took over 42 seconds. Not 40 seconds, not 45 seconds, but consistently around 42 seconds!!
This was maddening. The same API endpoints, the same network, but completely different performance characteristics. I was ready to throw my computer out of the window.
My First (Wrong) Assumption
Like many developers facing performance issues with async code, I immediately blamed async/await. I thought, "Maybe blocking synchronous calls would be faster?" So I converted all my async methods to synchronous ones using .Result() and .Wait().
Spoiler alert: This didn't help at all. The calls still took 42 seconds.
I want to apologize to async/await for doubting you. You weren't the problem.
Building a Diagnostic Tool
Instead of blindly trying different solutions, I decided to be methodical. I created a diagnostic console application that would test different scenarios and measure exactly where the delay was happening.
Here's what I tested:
Phase 1: Network Analysis