2 ms·
I don't know what's a fair way to do this for all languages listed in the benchmark, but for Go vs Node the only fair way would be to use a single goroutine to
by piterrro 2y ago
I don't know what's a fair way to do this for all languages listed in the benchmark, but for Go vs Node the only fair way would be to use a single goroutine to schedule timers and another one to pick them up when they tick, this way we don't create a huge stack and it's much more comparable to what you're really doing in Node.
Consider the following code:
package main
import (
"fmt"
"os"
"strconv"
"time"
)
func main() {
numTimers, _ := strconv.Atoi(os.Args[1])
timerChan := make(chan struct{})
// Goroutine 1: Schedule timers
go func() {
for i := 0; i < numTimers; i++ {
timer := time.NewTimer(10 * time.Second)
go func(t *time.Timer) {
<-t.C
timerChan <- struct{}{}
}(timer)
}
}()
// Goroutine 2: Receive and process timer signals
for i := 0; i < numTimers; i++ {
<-timerChan
}
}
Also for Node it's weird not to have Bun and Deno included. I suppose you can have other runtimes for other languages too.
In the end I think this benchmark is comparing different things and not really useful for anything...