forked from ChilliCream/graphql-platform
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f7951b6
commit 447bf4f
Showing
75 changed files
with
240,731 additions
and
235 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
#!/bin/sh | ||
|
||
BASEDIR=$(dirname "$0") | ||
src=$BASEDIR/src | ||
|
||
rm -rf BenchmarkDotNet.Artifacts | ||
rm -rf src/Benchmarks.Execution/bin | ||
rm -rf src/Benchmarks.Execution/obj | ||
rm -rf $src/Benchmarks.Execution/bin | ||
rm -rf $src/Benchmarks.Execution/obj | ||
|
||
dotnet run --project src/Benchmarks.Execution/ -c release --filter HotChocolate.Benchmarks.* | ||
dotnet run --project $src/Benchmarks.Execution/ -c release --filter HotChocolate.Benchmarks.Extension* | ||
|
||
rm -rf src/Benchmarks.Execution/bin | ||
rm -rf src/Benchmarks.Execution/obj | ||
rm -rf $src/Benchmarks.Execution/bin | ||
rm -rf $src/Benchmarks.Execution/obj |
174 changes: 174 additions & 0 deletions
174
src/HotChocolate/Benchmarks/src/Benchmarks.Execution/ExtensionDataBenchmarks.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,174 @@ | ||
|
||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.Collections.Immutable; | ||
using System.Diagnostics.CodeAnalysis; | ||
using BenchmarkDotNet.Attributes; | ||
|
||
namespace HotChocolate.Benchmarks; | ||
|
||
[RPlotExporter, CategoriesColumn, RankColumn, MeanColumn, MedianColumn, MemoryDiagnoser] | ||
public class ExtensionDataBenchmarks | ||
{ | ||
private readonly ExtensionData data1 = new ExtensionData { ["abc"] = "abc" }; | ||
private readonly ExtensionData2 data2 = new ExtensionData2 { ["abc"] = "abc" }; | ||
|
||
[Benchmark] | ||
public ExtensionData Create_ExtensionData() | ||
=> new(); | ||
|
||
[Benchmark] | ||
public ExtensionData2 Create_ExtensionData_2() | ||
=> new(); | ||
|
||
[Benchmark] | ||
public ExtensionData Create_ExtensionData_Set_1() | ||
{ | ||
var data = new ExtensionData(); | ||
data["1"] = "1"; | ||
return data; | ||
} | ||
|
||
[Benchmark] | ||
public ExtensionData2 Create_ExtensionData_2_Set_1() | ||
{ | ||
var data = new ExtensionData2(); | ||
data["1"] = "1"; | ||
return data; | ||
} | ||
|
||
[Benchmark] | ||
public ExtensionData Create_ExtensionData_Set_2() | ||
{ | ||
var data = new ExtensionData(); | ||
for (int i = 0; i < 2; i++) | ||
{ | ||
data[i.ToString()] = i; | ||
} | ||
return data; | ||
} | ||
|
||
[Benchmark] | ||
public ExtensionData2 Create_ExtensionData_2_Set_2() | ||
{ | ||
var data = new ExtensionData2(); | ||
for (int i = 0; i < 2; i++) | ||
{ | ||
data[i.ToString()] = i; | ||
} | ||
return data; | ||
} | ||
|
||
[Benchmark] | ||
public ExtensionData Create_ExtensionData_Set_10() | ||
{ | ||
var data = new ExtensionData(); | ||
for (int i = 0; i < 10; i++) | ||
{ | ||
data[i.ToString()] = i; | ||
} | ||
return data; | ||
} | ||
|
||
[Benchmark] | ||
public ExtensionData2 Create_ExtensionData_2_Set_10() | ||
{ | ||
var data = new ExtensionData2(); | ||
for (int i = 0; i < 10; i++) | ||
{ | ||
data[i.ToString()] = i; | ||
} | ||
return data; | ||
} | ||
|
||
[Benchmark] | ||
public object? Create_ExtensionData_Get_1() | ||
{ | ||
return data1["abc"]; | ||
} | ||
|
||
[Benchmark] | ||
public object? Create_ExtensionData_2_Get_1() | ||
{ | ||
return data2["abc"]; | ||
} | ||
} | ||
|
||
|
||
public class ExtensionData2 : IDictionary<string, object?> | ||
{ | ||
private IDictionary<string, object?>? _; | ||
|
||
private IDictionary<string, object?> Dict() | ||
=> _ ??= new Dictionary<string, object?>(); | ||
|
||
public object? this[string key] | ||
{ | ||
get => Dict()[key]; | ||
set => Dict()[key] = value; | ||
} | ||
|
||
public ICollection<string> Keys => throw new NotImplementedException(); | ||
|
||
public ICollection<object?> Values => throw new NotImplementedException(); | ||
|
||
public int Count => throw new NotImplementedException(); | ||
|
||
public bool IsReadOnly => throw new NotImplementedException(); | ||
|
||
public void Add(string key, object? value) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public void Add(KeyValuePair<string, object?> item) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public void Clear() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public bool Contains(KeyValuePair<string, object?> item) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public bool ContainsKey(string key) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public void CopyTo(KeyValuePair<string, object?>[] array, int arrayIndex) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public IEnumerator<KeyValuePair<string, object?>> GetEnumerator() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public bool Remove(string key) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public bool Remove(KeyValuePair<string, object?> item) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public bool TryGetValue(string key, [MaybeNullWhen(false)] out object? value) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
IEnumerator IEnumerable.GetEnumerator() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.