Skip to content

Instantly share code, notes, and snippets.

@ozekik
Created March 20, 2020 20:20
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 ozekik/636a8fb521401070e02e010ce591fa92 to your computer and use it in GitHub Desktop.
Save ozekik/636a8fb521401070e02e010ce591fa92 to your computer and use it in GitHub Desktop.
LightRDF Bench 2
import lightrdf
import sys
parser = lightrdf.nt.Parser()
cnt = 0
for triple in parser.parse(sys.argv[1]):
cnt += 1
print(cnt)
from rdflib.plugins.parsers.ntriples import NTriplesParser
import sys
class Sink(object):
def __init__(self):
self.cnt = 0
def triple(self, s, p, o):
self.cnt += 1
sink = Sink()
parser = NTriplesParser(sink)
with open(sys.argv[1], "rb") as f:
parser.parse(f)
print(sink.cnt)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment