On Wed, Dec 19, 2018 at 1:29 PM Tamás Király <rock8...@gmail.com> wrote:
>
> my task is to update a value every microsecond.
> i did an it with an infinite loop with time.Sleep like this
>
> https://play.golang.org/p/JiN3_5KiGOO
>
> this causes me about 50-60% of CPU usage on my machine but i made another 
> version with time.After:
>
> https://play.golang.org/p/PQHsNq261qZ
>
> this is 30%-40% of CPU usage. Can anyone optimize more this code so it does 
> not use a hilariously lot of CPU?

Have you tried using time.Tick or time.NewTicker?

Ian

-- 
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