From 99cb3bfbd31382e3458fdd9fbf6da4654b04b44e Mon Sep 17 00:00:00 2001 From: Robert Mosolgo Date: Thu, 23 Mar 2023 08:54:47 -0400 Subject: [PATCH] Fix benchmarks --- benchmark/run.rb | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/benchmark/run.rb b/benchmark/run.rb index 25c40d8a06..c1ee90ecf1 100644 --- a/benchmark/run.rb +++ b/benchmark/run.rb @@ -37,6 +37,7 @@ 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) } @@ -44,12 +45,11 @@ def self.run(task) 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 @@ -57,11 +57,8 @@ def self.run(task) 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)