F# vs TypeScript Performance - Sorting 1 Million Elements

preview_player
Показать описание
In this video we dive into the performance of F# (.NET) and TypeScript (Node) by comparing benchmarks sorting large datasets with various data types.

Chapters

02:28 - Benchmark Setup
03:40 - Detailed Results

Links:

About me: I'm Hamilton - Technologist / Tinypreneur. I build Simple Scalable Systems for effective product / business / creation cycles.

Connect with me:

# Support

Supporters get:
* Full source code access from courses / tutorials
* Exclusive discounts on products / courses

Plus you help me to keep experimenting / sharing!
Рекомендации по теме
Комментарии
Автор


Results: F# still wins overall, but TS performs a bit better in its number sorting

HAMYLABS
Автор

100% means 2 times faster, not 10 times

ganderston
Автор

Your benchmarks comparing the sorting of numbers are a bit misleading because the F# and TS code for `getRandomPositiveInteger()` return different ranges of integers. F#'s implementation returns integers 0 — 2147483647 (2^31 - 1), meanwhile the TS implementation returns integers 0 — 1.798e+308 (2^1024 - 1). Not only does this significantly decrease the chance of pre-sorted segments/runs occurring naturally in the random array, but it also has a significant runtime impact because Node (V8) numbers greater than 2^31 - 1 are heap allocated, as opposed to stack or register allocated (as it is in F#). Therefore, most numbers in your TS benchmark are actually getting heap allocated, which are obviously a lot slower to read from memory. But when I rerun your the TS benchmark with numbers in the same range as F#, the 1 million numbers case only takes 400ms on average on my 2018 Macbook Pro.

denniskats