Skip to content

Instantly share code, notes, and snippets.

@masao
Created August 18, 2022 02:17
Show Gist options
  • Save masao/398d9009cd8ba78d9da9283c8038c27d to your computer and use it in GitHub Desktop.
Save masao/398d9009cd8ba78d9da9283c8038c27d to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require "benchmark"
require "rubygems"
if ARGV.size < 1
puts <<-EOF
USAGE:
#$0 "~> 3.2.0"
or
#$0 "~> 3.1.0"
Install the versions of libraries with gem install before using this benchmark.
EOF
exit
end
v = ARGV.first
gem "rdf", v
gem "rdf-n3", v
require "rdf"
require "rdf/n3"
puts "RDF::VERSION: #{RDF::VERSION}"
puts "RDF::N3::VERSION: #{RDF::N3::VERSION}"
Benchmark.bm(15) do |r|
%w( test10k.n3 test100k.n3 test200k.n3 test1000k.n3 ).each do |file|
r.report(file) do
g = RDF::Graph.new
RDF::N3::Reader.open(file) do |reader|
count = 0
reader.each_statement do |statement|
g.insert << statement
count += 1
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment