Support

If you have a problem or need to report a bug please email : support@dsprobotics.com

There are 3 sections to this support area:

DOWNLOADS: access to product manuals, support files and drivers

HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects

USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here

NEW REGISTRATIONS - please contact us if you wish to register on the forum

Ruby cpu usage

For general discussion related FlowStone

Ruby cpu usage

Postby unkargherth » Sun Dec 02, 2012 6:57 pm

Hi fellows

As an SM user, I feel comfortable being able to calculate ( approximately) how much cpu a code module is using

There's anyway to do the same with ruby modules?

It seems not trivial, taking into account that ruby modules use the same "ruby instance" in the whole schematic, but event taking the module out to a new schematic to make the measurement possible, will be a great help

Any idea?
Free your memory, .. with a free(). Like a pointer
Cast a pointer into an integer and it becomes the integer...
Cast a pointer into a struct and it becomes the struct...
A pointer can overflow... or can crash...
Be a pointer my friend
unkargherth
 
Posts: 29
Joined: Fri Apr 08, 2005 9:46 pm

Re: Ruby cpu usage

Postby support » Tue Dec 04, 2012 12:44 pm

Tricky one. We don't have a way of doing this at the moment. It would be interesting to look into though.
User avatar
support
 
Posts: 151
Joined: Fri Sep 07, 2012 2:10 pm

Re: Ruby cpu usage

Postby trogluddite » Tue Dec 04, 2012 7:58 pm

Hmm, yes it would be interesting to know - though in reality we cannot easily do this for 'green' sections either.
Unlike code (always running), any event driven process is going to be hard to get precisely reliable results from - and this is further complicated by Ruby calling GDI (for graphics), or maybe external dll's, in which case it is hard with any CPU monitor to pick apart which part of the process is using what proportion of CPU. Readings are also very variable between different machines, so they will only provide very vague hints about their efficiency when you move them.

But there is a different kind of measurement that may be equally, or even more, useful - most often you would choose code/green/Ruby based on what will best allow you to perform a particular task.
So the question becomes, which is the most efficient way to use Ruby - what combinations of methods, loops, etc. will get you the best performance. And this is far easier to determine.
For example, consider a bit of code like this...
Code: Select all
start = time
10000.times do
   #TEST CODE
end
result = start - time

This will tell you how long a piece of code took to execute - and doing many times over allows a good average of results. Change the TEST CODE to some other routine that does the same thing, and you can compare them for efficiency.
We could also maybe add the "benchmark" libraryto FS from a standard Ruby installation (DWB has been working on a nice clean method for doing this). The "benchmark" library contains methods for doing similar measurements, but in a more accurate way, with a measure of actual CPU time used by only the Ruby thread - so disregarding other stuff that the CPU is doing at the same time (that's my reading of the doc's anyhow - I could be mistaken).
All schematics/modules I post are free for all to use - but a credit is always polite!
Don't stagnate, mutate to create!
User avatar
trogluddite
 
Posts: 1730
Joined: Fri Oct 22, 2010 12:46 am
Location: Yorkshire, UK


Return to General

Who is online

Users browsing this forum: Google [Bot] and 32 guests