Sha256: 4df988d95345ff0cdc3eb7e448488a90274aaa9b3de100f6728fe56d6cf0f120
Contents?: true
Size: 1.72 KB
Versions: 1
Compression:
Stored size: 1.72 KB
Contents
#!/usr/bin/env ruby # encoding: UTF-8 # frozen_string_literal: true require 'rubygems' require 'bundler/setup' require 'git_dump' require 'benchmark' require 'tmpdir' def measure(label, number = nil) label = "#{label} x#{number}" if number label = "#{label}:" result = nil print label.ljust(30) times = Benchmark.measure do (number || 1).times do |n| result = yield n end end puts " #{times}" result end puts "Using #{defined?(Rugged) ? 'libgit2' : 'git commands'}:" urandom = File.open('/dev/urandom') Dir.mktmpdir do |dir| dump = measure 'init' do GitDump.new(File.join(dir, 'bm.git'), :create => true) end builder = dump.new_version [ ['1K', 1_000, 1024], ['10M', 10, 10 * 1024 * 1024], ].each do |label, times, size| datas = Array.new(times) do urandom.read(size) end.each measure "store #{label} strings", times do |n| path = format('data%s%08d', label, n).scan(/.{1,2}/).join('/') data = datas.next builder.store(path, data) end files = Array.new(times) do |i| path = File.join(dir, "file#{i}") File.open(path, 'w') do |f| f.write(urandom.read(size)) end path end.each measure "store #{label} files", times do |n| path = format('file%s%08d', label, n).scan(/.{1,2}/).join('/') file = files.next builder.store_from(path, file) end end measure 'commit', 10 do builder.commit end measure 'read versions', 100 do dump.versions end entries = dump.versions.first.each_recursive.to_a measure 'read entries', entries.length do |n| entries[n].read end measure 'read entries to disk', entries.length do |n| entries[n].write_to(File.join(dir, 'out')) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
git_dump-0.1.1 | script/benchmark |