hi group I''m new in RubyonRails world i need to define a method that will generate random CPU utilization (0-100%) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 19 Nov 2008, at 15:36, amarime wrote:> > hi group > I''m new in RubyonRails world i need to define a method that will > generate random CPU utilization (0-100%)as in something that will create that amount of load on the computer it''s running on ? Fred> > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
no just by fake numbers that will be generated from the method inside the model On Nov 19, 11:42 am, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 19 Nov 2008, at 15:36, amarime wrote: > > > > > hi group > > I''m new in RubyonRails world i need to define a method that will > > generate random CPU utilization (0-100%) > > as in something that will create that amount of load on the computer > it''s running on ? > > Fred > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Two options: 1+rand(100) will give you a range of 1-100 (it will never show as 0%) rand(101) will give you a range of 0-100 (0% is possible) Basic ruby 101 to be honest. On 19 Nov 2008, at 17:58, amarime wrote:> no just by fake numbers that will be generated from the method inside > the model > On Nov 19, 11:42 am, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: >> On 19 Nov 2008, at 15:36, amarime wrote: >> >> >> >>> hi group >>> I''m new in RubyonRails world i need to define a method that will >>> generate random CPU utilization (0-100%) >> >> as in something that will create that amount of load on the computer >> it''s running on ?Best regards Peter De Berdt --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> 1+rand(100) will give you a range of 1-100 (it will never show as 0%) > rand(101) will give you a range of 0-100 (0% is possible)I don''t know what your actually trying to accomplish, but it doesn''t seem to me that simply generating random numbers between 0 and 100 would be a very realistic test of CPU load. Load on a CPU wouldn''t look like random noise. I think I would generate random numbers that add to another value in small increments in some form of moving average to produce a more realistic result. But, this depends on if you care about the value over time, or just need an instance in time value. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---