forked from dan-manges/mixology
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
Showing
16 changed files
with
180 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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,4 @@ | |||
source 'http://rubygems.org' | |||
|
|||
gem 'perftools.rb', :git => 'git://github.com/bearded/perftools.rb.git', :branch => 'perftools-1.8' | |||
gem 'mixology' |
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,18 @@ | |||
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: | |||
mixology (0.2.0) | |||
|
|||
PLATFORMS | |||
ruby | |||
|
|||
DEPENDENCIES | |||
mixology | |||
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,5 @@ | |||
## DCI vs Include ## | |||
|
|||
[Benchmarking DCI in Ruby](http://mikepackdev.com/blog_posts/22-benchmarking-dci-in-ruby) | |||
|
|||
Mike Pack |
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 | Original file line | 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 | Original file line | 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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,17 @@ | |||
require 'benchmark' | |||
require './runner' | |||
require 'mixology' | |||
|
|||
class DCIUser; end | |||
|
|||
Benchmark.bm do |bench| | |||
3.times do | |||
bench.report('DCI') do | |||
1000000.times do | |||
user = DCIUser.new | |||
user.mixin Runner | |||
user.run | |||
end | |||
end | |||
end | |||
end |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 | Original file line | 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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,13 @@ | |||
require 'perftools' | |||
require './runner' | |||
require 'mixology' | |||
|
|||
class DCIUser; end | |||
|
|||
PerfTools::CpuProfiler.start('/tmp/dci_profile_mixology') do | |||
1000000.times do | |||
user = DCIUser.new | |||
user.mixin 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 | Original file line | 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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,13 @@ | |||
require './runner' | |||
require './allocation' | |||
require 'mixology' | |||
|
|||
class DCIUser; end | |||
|
|||
p(Allocation.count do | |||
1000000.times do | |||
user = DCIUser.new | |||
user.mixin 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 | Original file line | 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 |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 | Original file line | 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 | Original file line | 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 | Original file line | 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 |