[Plugin] Plugin to profile/optimize code
-
This might be a duplicate effort, but I couldn't find anything beyond this thread:
http://sketchucation.com/forums/viewtopic.php?f=180&t=25101So... here is a SketchUp plugin that does basic profiling of each function call. It is modified from the stock profiler.rb that came with Ruby 1.8.7 (see https://github.com/ruby/ruby/blob/ruby_1_8_7/lib/profiler.rb). A good writeup of profiler.rb is found here: http://www.ibm.com/developerworks/opensource/tutorials/os-ruby2/section3.html
Usage
- Add the following line
require 'SU_Profiler/SU_Profiler.rb' - Add this at the start of the block to profile
SU_Profiler::start_profile - At the end of the block to profile, add
SU_Profiler::print_profile() # to print to ruby console
or
SU_Profiler::print_profile(filehandle) # to print to file
Output
The output will be something like this:
**```
% cumulative self self total
time seconds seconds calls ms/call ms/call name
29.07 1.87 1.87 48 39.02 39.02 Sketchup;;Drawingelement#material=
15.49 2.87 1.00 2095 0.48 0.70 BM_SimpleSolarStudy.inShadow
10.71 3.56 0.69 2066 0.33 5.67 Range#each
9.20 4.15 0.59 1 593.00 593.00 UI.savepanel
4.59 4.45 0.30 72 4.11 13.44 BM_SimpleSolarStudy;;SSS_sunData#calcSun
3.91 4.70 0.25 2376 0.11 0.18 Numeric#to_rad
3.66 4.94 0.24 8952 0.03 0.03 Float#*
2.42 5.09 0.16 4086 0.04 0.04 Float#/
1.68 5.20 0.11 2145 0.05 0.05 Fixnum#&
1.46 5.30 0.09 2095 0.04 0.04 Geom.intersect_line_plane
1.44 5.39 0.09 48 1.94 4.23 BM_SimpleSolarStudy.getCentroid
1.21 5.47 0.08 1668 0.05 0.05 String#==
1.21 5.54 0.08 9854 0.01 0.01 Array#[]
1.21 5.62 0.08 1 78.00 78.00 UI.inputbox
1.20 5.70 0.08 2245 0.03 0.03 Hash#[]
1.20 5.78 0.08 48 1.60 3.87 BM_SimpleSolarStudy.hsv2rgb
0.98 5.84 0.06 192 0.33 0.57 BM_SimpleSolarStudy.remapVal
0.96 5.90 0.06 2240 0.03 0.03 Kernel.nil?
0.96 5.96 0.06 72 0.86 0.86 BM_SimpleSolarStudy;;SSS_sunData#calcJD
0.95 6.02 0.06 2095 0.03 0.03 Sketchup;;Face#classify_pointLatest version: 1.00, updated 2013-Aug-8 [SU_Profiler.zip](/uploads/imported_attachments/24FQ_SU_Profiler.zip) Example usage: [profiler_test.rb](/uploads/imported_attachments/Q1CQ_profiler_test.rb) - Add the following line
-
That is mighty interesting. Thanks for sharing.
-
It seams to be Printing to the console ok!
Can't say I know how to profile properly, so this tool will be valuable for me. Thanks! -
cheers for this,
did you test it with 'Developer Console' extension turned 'on', it seems to curry the returns
john
-
No, I didn't test it with the Developer Console. I was thinking the people who would most want to profile their code would have such a huge trace that they would want to dump to a file. Maybe printing to stdout should have an option of showing the top N entries...
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement