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
hutch-xamplr-1.0.3 lib/xamplr/test-support/bench-cache.rb
hutch-xamplr-1.0.4 lib/xamplr/test-support/bench-cache.rb
hutch-xamplr-1.0.5 lib/xamplr/test-support/bench-cache.rb
hutch-xamplr-1.1.0 lib/xamplr/test-support/bench-cache.rb
hutch-xamplr-1.1.1 lib/xamplr/test-support/bench-cache.rb
hutch-xamplr-1.1.2 lib/xamplr/test-support/bench-cache.rb
hutch-xamplr-1.1.4 lib/xamplr/test-support/bench-cache.rb
hutch-xamplr-1.2.0 lib/xamplr/test-support/bench-cache.rb
hutch-xamplr-1.3.0 lib/xamplr/test-support/bench-cache.rb
hutch-xamplr-1.3.1 lib/xamplr/test-support/bench-cache.rb
hutch-xamplr-1.3.10 lib/xamplr/test-support/bench-cache.rb
hutch-xamplr-1.3.11 lib/xamplr/test-support/bench-cache.rb
hutch-xamplr-1.3.12 lib/xamplr/test-support/bench-cache.rb
hutch-xamplr-1.3.13 lib/xamplr/test-support/bench-cache.rb
hutch-xamplr-1.3.14 lib/xamplr/test-support/bench-cache.rb
hutch-xamplr-1.3.3 lib/xamplr/test-support/bench-cache.rb
hutch-xamplr-1.3.8 lib/xamplr/test-support/bench-cache.rb
hutch-xamplr-1.3.9 lib/xamplr/test-support/bench-cache.rb
xamplr-1.9.20 lib/xamplr/test-support/bench-cache.rb
xamplr-1.9.18 lib/xamplr/test-support/bench-cache.rb