For reference, similar code under Java consumes 2.5 % CPU.

I tested the Go code under OSX, and it is roughly 10%, which seems to be very 
high. Might be because the “context switching” is performed/attributed to the 
process (since it is internal), where for other systems it is the system call 
only, and so most of the cost is attributed to system/kernel activity.



> On Sep 16, 2018, at 8:47 AM, Lei Ni <nile...@gmail.com> wrote:
> 
> import (
>   "time"
> )
> 
> func main() {
>   ticker := time.NewTicker(time.Millisecond)
>   defer ticker.Stop()
>   for range ticker.C {
>   }
> }
> 

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to