Search code examples
goosx-elcapitan

Only 100% shown on benchmark run


I was just doing a 10Million insert benchmark to see the performance of a small cache system I'm building. While observing the Activity Monitor I noticed that the main Go process only shows 100% (of the 800%) CPU.

Do I need to split my loops into routines to make it split up to all 8 cores or is there another reason?

I'm not posting code as the test code is not much more than a loop in a testing function in the main body.


Solution

  • Your application is using only one thread so it's correct that there is only one core that run at 100%.
    If you want use more than one core you must use more than one go routine, remeber to set GOMAXPROCS shell enviroment or your application will use only one core.
    Remember that it's possible that your application could be even slower using more than one process because if your behaviuor is intrinsically sequential you cannot speed up the application just adding more goroutine. You can take a real advantage of multi threading only if your behaviour is intrinsically parallel.