Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ decompile
depersist
deprioritization
deprioritized
Diagnoser
Dispatchable
DOCKERHUB
drawio
Expand Down
8 changes: 8 additions & 0 deletions src/HotChocolate/Core/benchmarks/Benchmarks.slnx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Solution>
<Folder Name="/Execution.Abstractions.Benchmarks/">
<Project Path="Execution.Abstractions.Benchmarks/HotChocolate.Execution.Abstractions.Benchmarks.csproj" />
</Folder>
<Folder Name="/Validation.Benchmarks/">
<Project Path="Validation.Benchmarks/HotChocolate.Validation.Benchmarks.csproj" />
</Folder>
</Solution>
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using BenchmarkDotNet.Running;
using HotChocolate.Execution.Abstractions.Benchmarks;

BenchmarkSwitcher.FromAssembly(typeof(PathBenchmark).Assembly).Run(args);
BenchmarkSwitcher
.FromAssembly(typeof(Program).Assembly)
.Run(args);
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
using HotChocolate.Language;

namespace HotChocolate.Validation.Benchmarks;

[MemoryDiagnoser]
[ShortRunJob(RuntimeMoniker.Net10_0)]
public class ExtraLargeSchema1Benchmark : ValidationBenchmarkBase
{
protected override string SchemaDocumentFile => "__resources__/extra-large-schema-1.graphqls";
protected override string DocumentFile => "__resources__/extra-large-schema-1-query.graphql";

[Benchmark]
public DocumentValidatorResult ExtraLargeSchema1Validation()
{
return Validator.Validate(
schema: Schema,
documentId: new OperationDocumentId("extra-large-schema-1-query"),
document: Document,
onlyNonCacheable: false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,10 @@
<ProjectReference Include="..\..\src\Validation\HotChocolate.Validation.csproj" />
</ItemGroup>

<ItemGroup>
<None Update="__resources__\*">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
using HotChocolate.Language;

namespace HotChocolate.Validation.Benchmarks;

[MemoryDiagnoser]
[ShortRunJob(RuntimeMoniker.Net10_0)]
public class LargeSchema1Benchmark : ValidationBenchmarkBase
{
protected override string SchemaDocumentFile => "__resources__/large-schema-1.graphqls";
protected override string DocumentFile => "__resources__/large-schema-1-query.graphql";

[Benchmark]
public DocumentValidatorResult LargeSchema1Validation()
{
return Validator.Validate(
schema: Schema,
documentId: new OperationDocumentId("large-schema-1-query"),
document: Document,
onlyNonCacheable: false);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
using HotChocolate.Language;

namespace HotChocolate.Validation.Benchmarks;

[MemoryDiagnoser]
[ShortRunJob(RuntimeMoniker.Net10_0)]
public class LargeSchema2Benchmark : ValidationBenchmarkBase
{
protected override string SchemaDocumentFile => "__resources__/large-schema-2.graphqls";
protected override string DocumentFile => "__resources__/large-schema-2-query.graphql";

[Benchmark]
public DocumentValidatorResult LargeSchema2Validation()
{
return Validator.Validate(
schema: Schema,
documentId: new OperationDocumentId("large-schema-2-query"),
document: Document,
onlyNonCacheable: false);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
using HotChocolate.Language;

namespace HotChocolate.Validation.Benchmarks;

[MemoryDiagnoser]
[ShortRunJob(RuntimeMoniker.Net10_0)]
public class ManyFragmentsBenchmark : ValidationBenchmarkBase
{
protected override string SchemaDocumentFile => "__resources__/many-fragments.graphqls";
protected override string DocumentFile => "__resources__/many-fragments-query.graphql";

[Benchmark]
public DocumentValidatorResult ManyFragmentsValidation()
{
return Validator.Validate(
schema: Schema,
documentId: new OperationDocumentId("many-fragments-query"),
document: Document,
onlyNonCacheable: false);
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
using HotChocolate;
using HotChocolate.Language;
using HotChocolate.Types;
using HotChocolate.Validation;
using HotChocolate.Validation.Rules;

namespace HotChocolate.Validation.Benchmarks;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using BenchmarkDotNet.Running;
using HotChocolate.Validation.Benchmarks;

BenchmarkSwitcher.FromAssembly(typeof(OverlappingFieldsMergedBenchmark).Assembly).Run(args);
BenchmarkSwitcher
.FromAssembly(typeof(Program).Assembly)
.Run(args);
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using BenchmarkDotNet.Attributes;
using HotChocolate.Language;
using HotChocolate.Types;
using Microsoft.Extensions.DependencyInjection;

namespace HotChocolate.Validation.Benchmarks;

public abstract class ValidationBenchmarkBase
{
protected abstract string SchemaDocumentFile { get; }
protected abstract string DocumentFile { get; }

protected Schema Schema = null!;
protected DocumentValidator Validator = null!;
protected DocumentNode Document = null!;

[GlobalSetup]
public void GlobalSetup()
{
var schemaDocument = Utf8GraphQLParser.Parse(File.ReadAllText(SchemaDocumentFile));
var schemaBuilder = SchemaBuilder.New();

// Register stubs for custom scalars.
var customScalars = schemaDocument.Definitions.OfType<ScalarTypeDefinitionNode>()
.Where(s => !Scalars.IsBuiltIn(s.Name.Value));

foreach (var scalar in customScalars)
{
schemaBuilder.AddType(new AnyType(scalar.Name.Value));
}

Schema = schemaBuilder
.AddDocument(schemaDocument)
.Use(next => next)
.Create();

Validator = DocumentValidatorBuilder.New().AddDefaultRules().Build();
Document = Utf8GraphQLParser.Parse(File.ReadAllText(DocumentFile));
}
}
Loading
Loading