A simple benchmark comparing java loom virtual thread and kotlin coroutines

A simple benchmark comparing java loom virtual thread and kotlin coroutines

Have seen many discussions comparing them but didn’t really see any benchmark numbers, so I decide to do a simple benchmark with the same ‘concurrent prime sieve’ algorithm golang uses on its [homepage]([https://golang.org/](https://golang.org/)) to demonstrate its goroutine performance. The [result]([https://programming-language-benchmarks.vercel.app/problem/prime-sieve](https://programming-language-benchmarks.vercel.app/problem/prime-sieve) shows kotlin coroutines (on JVM16) is ~2.5x slower than go(1.16.3), while java loom(ea jdk build 17-loom+6-225) is ~4.5x slower. The result is a little surprising to me, loom is not as performant as I was expecting. 🙁

Since I’m very new to loom API, any suggstions on improvement or bug fix of the code is more than welcome.

btw, I originally posted in java sub r for discussion but not allowed, why? 🙁

submitted by /u/hanabi1224
[link] [comments]