-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 56eaab2
Showing
10 changed files
with
129 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
source 'http://rubygems.org' | ||
|
||
gem 'perftools.rb', :git => 'git://github.com/bearded/perftools.rb.git', :branch => 'perftools-1.8' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
GIT | ||
remote: git://github.com/bearded/perftools.rb.git | ||
revision: df73f93e4dda8953e77ba3be2945f4bf806b07cf | ||
branch: perftools-1.8 | ||
specs: | ||
perftools.rb (0.5.6) | ||
|
||
GEM | ||
remote: http://rubygems.org/ | ||
specs: | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
perftools.rb! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Taken from Aaron Patterson's blog | ||
# http://tenderlovemaking.com/2011/06/29/i-want-dtrace-probes-in-ruby/ | ||
|
||
module Allocation | ||
def self.count | ||
GC.disable | ||
before = ObjectSpace.count_objects | ||
yield | ||
after = ObjectSpace.count_objects | ||
after.each { |k,v| after[k] = v - before[k] } | ||
GC.enable | ||
after | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
require 'benchmark' | ||
require './runner' | ||
|
||
class DCIUser; end | ||
|
||
Benchmark.bm do |bench| | ||
3.times do | ||
bench.report('DCI') do | ||
1000000.times do | ||
user = DCIUser.new | ||
user.extend Runner | ||
user.run | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
require 'perftools' | ||
require './runner' | ||
|
||
class DCIUser; end | ||
|
||
PerfTools::CpuProfiler.start('/tmp/dci_profile') do | ||
1000000.times do | ||
user = DCIUser.new | ||
user.extend Runner | ||
user.run | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
require './runner' | ||
require './allocation' | ||
|
||
class DCIUser; end | ||
|
||
p(Allocation.count do | ||
1000000.times do | ||
user = DCIUser.new | ||
user.extend Runner | ||
user.run | ||
end | ||
end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
require 'benchmark' | ||
require './runner' | ||
|
||
class IncludeUser | ||
include Runner | ||
end | ||
|
||
Benchmark.bm do |bench| | ||
3.times do | ||
bench.report('include') do | ||
1000000.times do | ||
user = IncludeUser.new | ||
user.run | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
require 'perftools' | ||
require './runner' | ||
|
||
class IncludeUser | ||
include Runner | ||
end | ||
|
||
PerfTools::CpuProfiler.start('/tmp/include_profile') do | ||
1000000.times do | ||
user = IncludeUser.new | ||
user.run | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
require './runner' | ||
require './allocation' | ||
|
||
class IncludeUser | ||
include Runner | ||
end | ||
|
||
p(Allocation.count do | ||
1000000.times do | ||
user = IncludeUser.new | ||
user.run | ||
end | ||
end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module Runner | ||
def self.included(base) | ||
# p "Included into #{base.name}" | ||
end | ||
|
||
def self.extended(base) | ||
# p "Extended into #{base.class.name}" | ||
end | ||
|
||
def run | ||
Math.tan(Math::PI / 4) | ||
end | ||
end |