Last active
February 27, 2016 16:16
-
-
Save no-reply/de7e002c37f7af2ed168 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rdf/turtle' | |
require 'json/ld' | |
g = RDF::Graph.load('http://json-ld.org/test-suite/reports/ruby-earl.ttl') | |
File.open('ruby-earl.json', 'w') { |file| file.write(g.dump(:jsonld, standard_prefixes: true)) } | |
File.open('ruby-earl.nt', 'w') { |file| file.write(g.dump(:ntriples)) } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# With Defoult JSON Parser | |
RUBY_VERSION # => "2.1.0" | |
require 'json/ld' | |
require 'benchmark' | |
puts Benchmark.bmbm { |bm| bm.report { JSON::LD::API.toRdf(File.open('ruby-earl.json')) } } | |
# Rehearsal ------------------------------------ | |
# 0.480000 0.030000 0.510000 ( 0.520427) | |
# --------------------------- total: 0.510000sec | |
# | |
# user system total real | |
# 0.420000 0.000000 0.420000 ( 0.425897) | |
# 0.420000 0.000000 0.420000 ( 0.425897) | |
JSON::LD::API.toRdf(File.open('ruby-earl.json')).count # => 3642 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# With OJ | |
RUBY_VERSION # => "2.1.0" | |
require 'oj' | |
require 'json/ld' | |
require 'benchmark' | |
puts Benchmark.bmbm { |bm| bm.report { JSON::LD::API.toRdf(File.open('ruby-earl.json')) } } | |
# Rehearsal ------------------------------------ | |
# 0.470000 0.020000 0.490000 ( 0.490904) | |
# --------------------------- total: 0.490000sec | |
# | |
# user system total real | |
# 0.410000 0.000000 0.410000 ( 0.418465) | |
# 0.410000 0.000000 0.410000 ( 0.418465) | |
JSON::LD::API.toRdf(File.open('ruby-earl.json')).count # => 3642 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# For NTriples | |
require 'rdf/ntriples' | |
require 'benchmark' | |
Benchmark.bmbm { |bm| bm.report { RDF::Reader.open('ruby-earl.nt').count } } | |
# Rehearsal ------------------------------------ | |
# 0.370000 0.010000 0.380000 ( 0.374357) | |
# --------------------------- total: 0.380000sec | |
# | |
# user system total real | |
# 0.370000 0.000000 0.370000 ( 0.369633) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment