No commit activity in last 3 years
No release in over 3 years
RubyMotion extension to log method runtime without adding a single line of code to original class.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

Simple Profiler for RubyMotion

motion-simple-profiler is a RubyMotion extension to log method runtime without adding a single line of code to original class.

Use it when you need to know how long it takes for a function to run, but you don't want to use tools like instruments.

Install

  1. gem 'motion-simple-profiler'
  2. require 'motion-simple-profiler' or add to your Gemfile

Usage

class MyClass
  def long_running_task
    # ... run the task
  end
end

Profiler.profile MyClass, :long_running_task 

Running self.long_running_task will print:

MyClass#long_running_task runtime: 1.63304 s

Customization

You can modify the profiler log output by override the Profiler::ObjectExt#profile_log method.

For example:

module Profiler
  module ObjectExt
    def profile_log(clazz_name, method_name, start_time, end_time)
      puts "*** %s#%s -> %.5fs" % [clazz_name, method_name, (end_time-start_time).to_f]
    end
  end
end

Same example above will print:

*** MyClass#long_running_task -> 1.63304s

About

motion-simple-profiler is inspired by Ruby AOP in 12 lines of Code and NanoProfiler.

License

Please refer to LICENSE.