Skip to content

Instantly share code, notes, and snippets.

@sapphyrus
Created August 22, 2019 22:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sapphyrus/3aab81ad06949c3743ad91e20ccf7c65 to your computer and use it in GitHub Desktop.
Save sapphyrus/3aab81ad06949c3743ad91e20ccf7c65 to your computer and use it in GitHub Desktop.
require "bundler/inline"
gemfile do
source "https://rubygems.org"
gem "vdf4r"
gem "vdf"
require "benchmark"
end
def benchmark_file(filename)
File.open(filename) do |file|
Benchmark.bm do |benchmark|
benchmark.report("vdf") do
VDF.parse(file.read)
end
file.rewind #required for vdf4r
benchmark.report("vdf4r") do
parser = VDF4R::Parser.new(file)
parser.parse
end
end
end
end
["small.vdf", "items_game.txt"].each do |filename|
puts filename
benchmark_file(filename)
puts
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment