From: forgottenwizard Date: 2007-09-19T01:38:35+09:00 Subject: Re: CPU Usage not near 100% when running code On 01:03 Wed 19 Sep , Robert Klemme wrote: > 2007/9/18, SpringFlowers AutumnMoon : > > Robert Klemme wrote: > > > 2007/9/18, SpringFlowers AutumnMoon : > > > > > Maybe your process is IO bound - probably without you being aware of > > > it (e.g. through paging, network IO, IPC or such). > > > > i can be just running calculations or just the following: > > > > require 'benchmark' > > > > n = 10_000_000 > > b = 123 > > c = 456 > > > > Benchmark.bm do |x| > > x.report { for i in 1..n; a = b + c; end } > > x.report { n.times do ; a = b + c; end } > > x.report { 1.upto(n) do ; a = b + c; end } > > end > > > > > > If I run the same code on a Mac with single core, the CPU meter will go > > to 100%. In the old days when I had a single Intel Windows XP machine, > > calculation intensive programs will make it go to 100% too. > > > > if the Ruby VM uses only one core, then why won't one core go to 100%? > > Probably because the OS moves the process between cores. See whether > you can switch off one core or make the process sticky. > > Kind regards > > robert > Might be a stupid question, but could it be that there is a latency somewhere else that could be slowing you down? The OS is the only thing that should limit your CPU usage, and unless you're using a system quota (another possiblity), then it should be able to max out your CPU.