Skip to content

Commit

Permalink
Fix benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
rmosolgo committed Mar 23, 2023
1 parent cae09ec commit 99cb3bf
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions benchmark/run.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,31 +37,28 @@ def self.run(task)
x.report("validate - big query") { BIG_SCHEMA.validate(BIG_QUERY) }
x.report("validate - fields will merge") { FIELDS_WILL_MERGE_SCHEMA.validate(FIELDS_WILL_MERGE_QUERY) }
when "scan"
require "graphql/c_parser"
x.report("scan c - introspection") { GraphQL.scan_with_c(QUERY_STRING) }
x.report("scan - introspection") { GraphQL.scan_with_ruby(QUERY_STRING) }
x.report("scan c - fragments") { GraphQL.scan_with_c(ABSTRACT_FRAGMENTS_2_QUERY_STRING) }
x.report("scan - fragments") { GraphQL.scan_with_ruby(ABSTRACT_FRAGMENTS_2_QUERY_STRING) }
x.report("scan c - big query") { GraphQL.scan_with_c(BIG_QUERY_STRING) }
x.report("scan - big query") { GraphQL.scan_with_ruby(BIG_QUERY_STRING) }
when "parse"
x.report("parse c - introspection") { GraphQL.parse_with_c(QUERY_STRING) }
x.report("parse - introspection") { GraphQL.parse_with_racc(QUERY_STRING) }
x.report("parse c - fragments") { GraphQL.parse_with_c(ABSTRACT_FRAGMENTS_2_QUERY_STRING) }
x.report("parse - fragments") { GraphQL.parse_with_racc(ABSTRACT_FRAGMENTS_2_QUERY_STRING) }
x.report("parse c - big query") { GraphQL.parse_with_c(BIG_QUERY_STRING) }
x.report("parse - big query") { GraphQL.parse_with_racc(BIG_QUERY_STRING) }
# Uncomment this to use the C parser:
# require "graphql/c_parser"
x.report("parse - introspection") { GraphQL.parse(QUERY_STRING) }
x.report("parse - fragments") { GraphQL.parse(ABSTRACT_FRAGMENTS_2_QUERY_STRING) }
x.report("parse - big query") { GraphQL.parse(BIG_QUERY_STRING) }
else
raise("Unexpected task #{task}")
end
end
end

def self.profile_parse
GraphQL.module_eval do
def self.scan(str)
GraphQL::Clexer.tokenize(str)
end
end
# To profile the C parser instead:
# require "graphql/c_parser"

report = MemoryProfiler.report do
GraphQL.parse(BIG_QUERY_STRING)
Expand Down

0 comments on commit 99cb3bf

Please sign in to comment.