transit-lang-cmp icon indicating copy to clipboard operation
transit-lang-cmp copied to clipboard

ASP.NET minimal API

Open MarkPflug opened this issue 2 years ago • 2 comments

An ASP.NET (C#) minimal API implementation that beats the current rust implementation (on my machine), with fewer than half the LOC.

Implementation LOC CSV Load (ms) Req/s
Trustit 213 987 844
Trannet 213 1457 649
TranNetMin 6.0 90 498 838
TranNetMin 7.0 90 551 902

See readme.md.

I would observe that this competition is a bit silly, because this API only generates 189 unique route responses. The entire app could be statically generated in a couple seconds. Perhaps an API that returns the next time that a bus will arrive at a given route/stop would make it a bit more dynamic, and realistic? As it stands, a client would be better off downloading the source .zip (13mb) data and doing everything client-side (and potentially offline), rather than requesting JSON payloads that might also measure in the multi-megabyte range.

MarkPflug avatar Oct 26 '22 19:10 MarkPflug

I think the reason you're faster than Rust is that you're cheating a bit: you're preparing full responses while loading the data.
Apparently the 'join' should be performed while serving web requests.

pkese avatar Oct 27 '22 00:10 pkese

Oh missed that one, actually wrote a similar PR #23 😅, but I haven't change the original request logic to make it on par with Rust, just that I'm initializing collections with proper capacity and it's now faster than Rust on my machine™️.

xoofx avatar Oct 28 '22 08:10 xoofx