diff --git a/README.md b/README.md index b9d4b9d..63e4c1a 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,15 @@ This is a profiling tool for SketchUp Ruby extensions. It wraps [`Benchmark`](ht ![Profiling in SketchUp](docs/images/profiling.png) +## Installation +There is no RBZ file! Download the ZIP archive of the code from https://github.com/SketchUp/speedup/archive/refs/heads/main.zip +Inside you will find the `src` folder, this contains the extension structure (`speedup.rb` and `speedup` folder). Manually drop those into your SketchUp Plugins folder(s) and restart SU. + +## UI +The extension adds a new sub-menu at: +`Extensions > Developer > SpeedUp` (From SketchUp 2021.1) +`Extensions > SpeedUp` (Before SketchUp 2021.1) + ## Setup [RubyProf](https://github.com/ruby-prof/ruby-prof) is a gem that needs to be compiled as it's installed. This prevents it from being installed from within SketchUp under Windows. To compile gems you need the [Ruby DevKit](https://rubyinstaller.org/add-ons/devkit.html) to be configured for the compiler. @@ -14,10 +23,16 @@ Additionally the gem started misbehaving in SketchUp 2017 and up. The profiler i To make it easier for SketchUp extension developers this extension bundles pre-compiled versions of RubyProf and will attempt to install it into SketchUp's gems directory. +To initialise this process, you need to run the `Setup` command from the sub-menu at: `Extensions > Developer > SpeedUp > Setup` (From SketchUp 2021.1) - `Extensions > SpeedUp > Setup` (Before SketchUp 2021.1) +If you have not run setup, you will see something like this in the Ruby Console: +``` +Warning: SpeedUp was unable to activate the ruby-prof gem. +Warning: SpeedUp was unable to load ruby-prof +``` + ### Compatibility / Version Chart | SketchUp | Ruby | ruby-prof (Win) | ruby-prof (Mac) | @@ -114,4 +129,4 @@ def fibonacci(number) end SpeedUp.profile { fibonacci(20) } -``` \ No newline at end of file +``` diff --git a/src/speedup/profile_test.rb b/src/speedup/profile_test.rb index 2e386fb..0ecce63 100644 --- a/src/speedup/profile_test.rb +++ b/src/speedup/profile_test.rb @@ -39,7 +39,11 @@ def self.reload random_profile_method = self.instance_methods.grep(/^profile_/).first path = self.instance_method(random_profile_method).source_location.first $VERBOSE = nil - load path + if File.exist?(path) + load path + else + UI.messagebox("Method '#{random_profile_method}' could not be loaded from path #{path.inspect}. Was the code pasted into the Ruby Console?") + end ensure $VERBOSE = original_verbose end