Skip to content

Instantly share code, notes, and snippets.

@casperisfine
Created April 9, 2020 13:55
Show Gist options
  • Save casperisfine/fc7872df42c3c72508f828d9edf3b129 to your computer and use it in GitHub Desktop.
Save casperisfine/fc7872df42c3c72508f828d9edf3b129 to your computer and use it in GitHub Desktop.
require 'fileutils'
require 'lmdb'
require 'benchmark/ips'
PATH = __FILE__
MAX_SIZE = 134217728 # 128 MB
FileUtils.mkdir_p('/tmp/lmdb-bench')
@env = ::LMDB.new('/tmp/lmdb-bench', mapsize: MAX_SIZE, nometasync: true, nosync: true)
@database = @env.database('bootsnap', create: true)
@database.put(PATH, File.read(PATH))
Benchmark.ips do |x|
x.report("current-bootsnap") { File.read(PATH) }
x.report("LMDB.get") { @database.get(PATH) }
end
Warming up --------------------------------------
current-bootsnap 5.064k i/100ms
LMDB.get 21.102k i/100ms
Calculating -------------------------------------
current-bootsnap 52.489k (± 2.1%) i/s - 263.328k in 5.019150s
LMDB.get 226.234k (± 1.5%) i/s - 1.140M in 5.038054s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment