redis_ring_client 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- redis_ring_client (0.0.1)
4
+ redis_ring_client (0.0.3)
5
5
  json
6
6
  redis
7
7
 
@@ -20,6 +20,7 @@ GEM
20
20
  rspec-expectations (2.5.0)
21
21
  diff-lcs (~> 1.1.2)
22
22
  rspec-mocks (2.5.0)
23
+ ruby-prof (0.9.2)
23
24
 
24
25
  PLATFORMS
25
26
  ruby
@@ -28,3 +29,4 @@ DEPENDENCIES
28
29
  mocha
29
30
  redis_ring_client!
30
31
  rspec
32
+ ruby-prof
@@ -0,0 +1,50 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.push File.expand_path("../../lib", __FILE__)
4
+
5
+ require 'redis_ring/client'
6
+ require 'redis'
7
+ require 'ruby-prof'
8
+
9
+ require 'benchmark'
10
+
11
+ def single_key_operations(redis, n)
12
+ redis.set("foo-#{n}", n)
13
+ redis.get("foo-#{n}")
14
+ redis.incr("bar-#{n}")
15
+ end
16
+
17
+ def multi_key_operations(redis, n)
18
+ redis.mset("foo-#{n}{x}", n, "bar-#{n}{x}", n)
19
+ redis.mget("foo-#{n}{x}", "bar-#{n}{x}")
20
+ end
21
+
22
+ def with_profiling(profile, &block)
23
+ if profile
24
+ result = RubyProf.profile do
25
+ block.call
26
+ end
27
+ printer = RubyProf::CallTreePrinter.new(result)
28
+ printer.print(File.open("#{profile}.kcg", 'w'))
29
+ else
30
+ block.call
31
+ end
32
+ end
33
+
34
+ count = (ARGV[0] || 10000).to_i
35
+ profile = ARGV[1]
36
+
37
+ redises = {
38
+ :redis_ring => (redis_proxy = RedisRing::Client::RingProxy.new),
39
+ :redis => redis_proxy.connection_for_key("some_key")
40
+ }
41
+
42
+ with_profiling(profile) do
43
+ Benchmark.bmbm do |b|
44
+ [:single_key_operations, :multi_key_operations].each do |method|
45
+ [:redis, :redis_ring].each do |redis_name|
46
+ b.report("#{redis_name} #{method}:") { count.times{|n| send(method, redises[redis_name], n)} }
47
+ end
48
+ end
49
+ end
50
+ end
@@ -183,7 +183,7 @@ module RedisRing
183
183
  end
184
184
 
185
185
  def connection_pool
186
- @connection_pool = ShardConnectionPool.new(ring_meta_data, @password, @db)
186
+ @connection_pool ||= ShardConnectionPool.new(ring_meta_data, @password, @db)
187
187
  end
188
188
 
189
189
  end
@@ -1,5 +1,5 @@
1
1
  module RedisRing
2
2
  module Client
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.4"
4
4
  end
5
5
  end
@@ -19,6 +19,7 @@ Gem::Specification.new do |s|
19
19
 
20
20
  s.add_development_dependency 'rspec'
21
21
  s.add_development_dependency 'mocha'
22
+ s.add_development_dependency 'ruby-prof'
22
23
 
23
24
  s.files = `git ls-files`.split("\n")
24
25
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 3
9
- version: 0.0.3
8
+ - 4
9
+ version: 0.0.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - Adam Pohorecki
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-03-08 00:00:00 +01:00
17
+ date: 2011-03-16 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -69,6 +69,19 @@ dependencies:
69
69
  version: "0"
70
70
  type: :development
71
71
  version_requirements: *id004
72
+ - !ruby/object:Gem::Dependency
73
+ name: ruby-prof
74
+ prerelease: false
75
+ requirement: &id005 !ruby/object:Gem::Requirement
76
+ none: false
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ segments:
81
+ - 0
82
+ version: "0"
83
+ type: :development
84
+ version_requirements: *id005
72
85
  description: The client counterpart to the RedisRing gem.
73
86
  email:
74
87
  - adam@pohorecki.pl
@@ -84,6 +97,7 @@ files:
84
97
  - Gemfile.lock
85
98
  - MIT-LICENSE.txt
86
99
  - Rakefile
100
+ - benchmarks/compared_to_redis.rb
87
101
  - lib/redis_ring/client.rb
88
102
  - lib/redis_ring/client/operation_definitions.rb
89
103
  - lib/redis_ring/client/ring_meta_data.rb