Sha256: b9b2677db2e7f8b2d4add78438e7ddaed5b94b554148bab35d91312412aba50a

Contents?: true

Size: 1.1 KB

Versions: 29

Compression:

Stored size: 1.1 KB

Contents

require "rubygems"
require "bench"
require File.dirname(__FILE__) + "/../lib/ohm"

Ohm.connect(:port => 6381)
Ohm.flush

class Event < Ohm::Model
  attribute :name
  set :attendees

  def validate
    assert_present :name
  end
end

event = Event.create(:name => "Ruby Tuesday")
array = []

benchmark "add to set with ohm redis" do
  Ohm.redis.sadd("foo", 1)
end

benchmark "add to set with ohm" do
  event.attendees << 1
end

Ohm.redis.sadd("bar", 1)
Ohm.redis.sadd("bar", 2)

benchmark "retrieve a set of two members with ohm redis" do
  Ohm.redis.sadd("bar", 3)
  Ohm.redis.srem("bar", 3)
  Ohm.redis.smembers("bar")
end

Ohm.redis.del("Event:#{event.id}:attendees")

event.attendees << 1
event.attendees << 2

benchmark "retrieve a set of two members with ohm" do
  event.attendees << 3
  event.attendees.delete(3)
  event.attendees
end

benchmark "retrieve membership status and set count" do
  Ohm.redis.scard("bar")
  Ohm.redis.sismember("bar", "1")
end

benchmark "retrieve set count" do
  Ohm.redis.scard("bar").zero?
end

benchmark "retrieve membership status" do
  Ohm.redis.sismember("bar", "1")
end

run 10_000

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
ohm-0.0.34 test/benchmarks.rb
ohm-0.0.33 test/benchmarks.rb
ohm-0.0.32 test/benchmarks.rb
ohm-0.0.31 test/benchmarks.rb
ohm-0.0.30 test/benchmarks.rb
ohm-0.0.29 test/benchmarks.rb
ohm-0.0.28 test/benchmarks.rb
ohm-0.0.27 test/benchmarks.rb
ohm-0.0.26 test/benchmarks.rb
ohm-0.0.25 test/benchmarks.rb
ohm-0.0.24 test/benchmarks.rb
ohm-0.0.23 test/benchmarks.rb
ohm-0.0.22 test/benchmarks.rb
ohm-0.0.21 test/benchmarks.rb
ohm-0.0.20 test/benchmarks.rb
ohm-0.0.19 test/benchmarks.rb
ohm-0.0.18 test/benchmarks.rb
ohm-0.0.17 test/benchmarks.rb
ohm-0.0.5 test/benchmarks.rb
ohm-0.0.6 test/benchmarks.rb