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
Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright
Ruby cpu usage
3 posts
• Page 1 of 1
Ruby cpu usage
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?
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
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
Tricky one. We don't have a way of doing this at the moment. It would be interesting to look into though.
-
support - Posts: 151
- Joined: Fri Sep 07, 2012 2:10 pm
Re: Ruby cpu usage
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...
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).
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!
Don't stagnate, mutate to create!
-
trogluddite - Posts: 1730
- Joined: Fri Oct 22, 2010 12:46 am
- Location: Yorkshire, UK
3 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 90 guests