Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

clockblock

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clockblock

  • 0.0.6
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Code Climate Build Status

Clockblock

Extend Clockblock::Timing in your class definition to add timers to your methods:

require 'clockblock'

class Foo
  extend Clockblock::Timing
  add_timing_to :bar

  def bar
    sleep 2
  end

end

f = Foo.new
f.bar

f.clockblock_timers[:bar]
# => {:started_at=>2012-07-26 16:04:03 -0400, :finished_at=>2012-07-26 16:04:05 -0400, :duration=>2.001059, :stage=>:finished}

Extend your instances with Clockblock::Timing to add timers to your methods:

require 'clockblock'

class Foo
  def bar
    sleep 2
  end
end

f = Foo.new
f.extend Clockblock::Timing
f.add_timing_to :bar
f.bar

f.clockblock_timers[:bar]
# => {:started_at=>2012-07-26 16:04:03 -0400, :finished_at=>2012-07-26 16:04:05 -0400, :duration=>2.001059, :stage=>:finished}

Extend your classes with Clockblock::Timing to add timers to your methods:

require 'clockblock'

class Foo
  def bar
    sleep 2
  end
end

Foo.extend Clockblock::Timing
Foo.add_timing_to :bar, :baz
puts Foo.instance_variable_get(:@future_timer_methods)
class Foo; def baz; sleep 2; end; end
f = Foo.new
f.bar
f.baz
puts f.clockblock_timers
# => {:bar=>{:started_at=>2012-07-30 10:43:48 -0400, :finished_at=>2012-07-30 10:43:49 -0400, :duration=>1.0004, :stage=>:finished}, :baz=>{:started_at=>2012-07-30 10:43:49 -0400, :finished_at=>2012-07-30 10:43:50 -0400, :duration=>1.000906, :stage=>:finished}}

Wrap your code in a Clockblock clock block to measure execution duration.

require 'clockblock'

class Foo

  def bar
    t = Clockblock::Timer.new
    result = t.clock do
      sleep 2 # replace 'sleep 2' with your code!
    end
    puts t.attributes
    result
  end
end

FAQs

Package last updated on 01 Aug 2012

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc