Skip to content

Commit dd86cbd

Browse files
committed
Add a benchmark for loading from SDL with c parser
1 parent ec1ae00 commit dd86cbd

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

Rakefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,12 @@ namespace :bench do
124124
GraphQLBenchmark.profile_to_definition
125125
end
126126

127+
desc "Load schema from SDL"
128+
task :profile_from_definition do
129+
prepare_benchmark
130+
GraphQLBenchmark.profile_from_definition
131+
end
132+
127133
desc "Compare GraphQL-Batch and GraphQL-Dataloader"
128134
task :profile_batch_loaders do
129135
prepare_benchmark

benchmark/run.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,26 @@ def self.profile_to_definition
487487
report.pretty_print
488488
end
489489

490+
def self.profile_from_definition
491+
require "graphql/c_parser"
492+
schema_str = SILLY_LARGE_SCHEMA.to_definition
493+
494+
Benchmark.ips do |x|
495+
x.report("from_definition") { GraphQL::Schema.from_definition(schema_str) }
496+
end
497+
498+
result = StackProf.run(mode: :wall, interval: 1) do
499+
GraphQL::Schema.from_definition(schema_str)
500+
end
501+
StackProf::Report.new(result).print_text
502+
503+
report = MemoryProfiler.report do
504+
GraphQL::Schema.from_definition(schema_str)
505+
end
506+
507+
report.pretty_print
508+
end
509+
490510
def self.profile_batch_loaders
491511
require_relative "./batch_loading"
492512
include BatchLoading

0 commit comments

Comments
 (0)