losvedir / transit-lang-cmp

Programming language comparison by reimplementing the same transit data app
MIT License
426 stars 29 forks source link

ASP.NET minimal API #21

Closed MarkPflug closed 1 year ago

MarkPflug commented 2 years ago

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.

pkese commented 2 years ago

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.

xoofx commented 2 years ago

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™️.