• Login
sketchucation logo sketchucation
  • Login
⚠️ Libfredo 15.4b | Minor release with bugfixes and improvements Update

[Plugin] Plugin to profile/optimize code

Scheduled Pinned Locked Moved Plugins
5 Posts 4 Posters 2.5k Views 4 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    dfwlarch
    last edited by 8 Aug 2013, 05:47

    This might be a duplicate effort, but I couldn't find anything beyond this thread:
    http://sketchucation.com/forums/viewtopic.php?f=180&t=25101

    So... 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

    1. Add the following line
      require 'SU_Profiler/SU_Profiler.rb'
    2. Add this at the start of the block to profile
      SU_Profiler::start_profile
    3. 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_point

    
    Latest 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)
    1 Reply Last reply Reply Quote 0
    • T Offline
      tt_su
      last edited by 9 Aug 2013, 01:45

      That is mighty interesting. Thanks for sharing.

      1 Reply Last reply Reply Quote 0
      • J Offline
        jolran
        last edited by 10 Aug 2013, 06:08

        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!

        1 Reply Last reply Reply Quote 0
        • D Offline
          driven
          last edited by 10 Aug 2013, 11:36

          cheers for this,

          did you test it with 'Developer Console' extension turned 'on', it seems to curry the returns

          john

          learn from the mistakes of others, you may not live long enough to make them all yourself...

          1 Reply Last reply Reply Quote 0
          • D Offline
            dfwlarch
            last edited by 12 Aug 2013, 05:54

            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...

            1 Reply Last reply Reply Quote 0
            • 1 / 1
            1 / 1
            • First post
              1/5
              Last post
            Buy SketchPlus
            Buy SUbD
            Buy WrapR
            Buy eBook
            Buy Modelur
            Buy Vertex Tools
            Buy SketchCuisine
            Buy FormFonts

            Advertisement