GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - jackross/clockblock: Wrap your code in a Clock Block to measure execution duration.

BranchesTags
Open more actions menu

Latest commit

 

History

24 Commits
24 Commits

Folders and files

NameName
Last commit message
Last commit date
lib
lib
 
 
spec
spec
 
 
.gitignore
.gitignore
 
 
.travis.yml
.travis.yml
 
 
Gemfile
Gemfile
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
Rakefile
Rakefile
 
 
clockblock.gemspec
clockblock.gemspec
 
 

Repository files navigation

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

About

Wrap your code in a Clock Block to measure execution duration.

Resources

Readme
MIT license
Activity

Stars

1 star

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.