Sha256: e4a0debe6c45f2e7e83248b0883a6c7769b5e57580dcf9f963e9c3e023cac5b8

Contents?: true

Size: 1.34 KB

Versions: 39

Compression:

Stored size: 1.34 KB

Contents

#!/usr/bin/env ruby

require "xamplr"
include Xampl

require "tmp/XamplExample"
include XamplExample

require "benchmark"
include Benchmark

#require 'persister/fsdb'
require 'wee-cache/cache'

class LRUCache < Cache::StorageCache
  def initialize(capacity=20)
    super(Cache::Strategy::LRU.new(capacity))
  end
end

class LRU2Cache < Cache::StorageCache
  def initialize(capacity=20)
    super(Cache::Strategy::LRU2.new(capacity))
  end
end

class LFUCache < Cache::StorageCache
  def initialize(capacity=20)
    super(Cache::Strategy::LFU.new(capacity))
  end
end


module Bench

  def Bench.go
    count = 1000
    capacity = 500

    bm(15) do | x |
      x.report("XamplCache") {
        cache = XamplCache.new(capacity)

        count.times { | i |
          cache[i] = i
        }
      }
      x.report("XamplCacheLFU") {
        cache = XamplCacheLFU.new(capacity)

        count.times { | i |
          cache[i] = i
        }
      }
      x.report("LRU") {
        cache = LRUCache.new(capacity)

        count.times { | i |
          cache[i] = i
        }
      }
      x.report("LRU2") {
        cache = LRU2Cache.new(capacity)

        count.times { | i |
          cache[i] = i
        }
      }
      x.report("LFU") {
        cache = LFUCache.new(capacity)

        count.times { | i |
          cache[i] = i
        }
      }
    end
  end
end

Bench.go

Version data entries

39 entries across 39 versions & 2 rubygems

Version Path
xamplr-1.9.16 lib/xamplr/test-support/bench-cache.rb
xamplr-1.9.15 lib/xamplr/test-support/bench-cache.rb
xamplr-1.9.14 lib/xamplr/test-support/bench-cache.rb
xamplr-1.9.13 lib/xamplr/test-support/bench-cache.rb
xamplr-1.9.12 lib/xamplr/test-support/bench-cache.rb
xamplr-1.9.11 lib/xamplr/test-support/bench-cache.rb
xamplr-1.9.10 lib/xamplr/test-support/bench-cache.rb
xamplr-1.9.9 lib/xamplr/test-support/bench-cache.rb
xamplr-1.9.8 lib/xamplr/test-support/bench-cache.rb
xamplr-1.9.7 lib/xamplr/test-support/bench-cache.rb
xamplr-1.9.6 lib/xamplr/test-support/bench-cache.rb
xamplr-1.9.5 lib/xamplr/test-support/bench-cache.rb
xamplr-1.9.4 lib/xamplr/test-support/bench-cache.rb
xamplr-1.9.3 lib/xamplr/test-support/bench-cache.rb
xamplr-1.9.2 lib/xamplr/test-support/bench-cache.rb
xamplr-1.9.1 lib/xamplr/test-support/bench-cache.rb
xamplr-1.9.0 lib/xamplr/test-support/bench-cache.rb
xamplr-1.3.15 lib/xamplr/test-support/bench-cache.rb
xamplr-1.2.0 lib/xamplr/test-support/bench-cache.rb