-
Notifications
You must be signed in to change notification settings - Fork 88
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
3aa9963
commit c03e3db
Showing
6 changed files
with
148 additions
and
23 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
``` | ||
BenchmarkDotNet v0.13.12, Windows 11 (10.0.22631.3155/23H2/2023Update/SunValley3) | ||
Intel Core i7-1065G7 CPU 1.30GHz, 1 CPU, 8 logical and 4 physical cores | ||
.NET SDK 8.0.200 | ||
[Host] : .NET 7.0.16 (7.0.1624.6629), X64 RyuJIT AVX2 | ||
DefaultJob : .NET 7.0.16 (7.0.1624.6629), X64 RyuJIT AVX2 | ||
``` | ||
| Method | Mean | Error | StdDev | Median | Gen0 | Gen1 | Allocated | | ||
|------------------------------------- |----------------:|----------------:|-----------------:|----------------:|----------:|----------:|-----------:| | ||
| Template | 91,883,381.6 ns | 3,632,849.07 ns | 10,597,191.25 ns | 89,313,550.0 ns | 8000.0000 | 2000.0000 | 35435008 B | | ||
| PropertyCopyLoop | 49,633,655.3 ns | 1,505,203.29 ns | 4,318,710.40 ns | 47,957,783.3 ns | 5500.0000 | 2666.6667 | 23333345 B | | ||
| UserDefinedFunctions | 29,551,473.2 ns | 677,400.84 ns | 1,910,621.08 ns | 29,457,092.2 ns | 2187.5000 | 62.5000 | 9336566 B | | ||
| ResolvePolicyAliasPath | 2,408.4 ns | 129.91 ns | 381.01 ns | 2,252.3 ns | 0.2861 | - | 1200 B | | ||
| GetResourceType | 297.3 ns | 9.93 ns | 28.18 ns | 287.5 ns | 0.0858 | - | 360 B | | ||
| CustomTypeDependencyGraph_GetOrdered | 876.7 ns | 17.50 ns | 31.55 ns | 878.1 ns | 0.1602 | - | 672 B | |
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,18 @@ | ||
``` | ||
BenchmarkDotNet v0.13.12, Windows 11 (10.0.22631.3155/23H2/2023Update/SunValley3) | ||
Intel Core i7-1065G7 CPU 1.30GHz, 1 CPU, 8 logical and 4 physical cores | ||
.NET SDK 8.0.200 | ||
[Host] : .NET 7.0.16 (7.0.1624.6629), X64 RyuJIT AVX2 | ||
DefaultJob : .NET 7.0.16 (7.0.1624.6629), X64 RyuJIT AVX2 | ||
``` | ||
| Method | Mean | Error | StdDev | Median | Gen0 | Gen1 | Gen2 | Allocated | | ||
|------------------------------------- |-----------------:|-----------------:|-----------------:|-----------------:|----------:|----------:|---------:|-----------:| | ||
| Template | 63,730,486.52 ns | 1,266,452.101 ns | 2,643,557.149 ns | 63,341,771.43 ns | 8285.7143 | 4142.8571 | 142.8571 | 35441751 B | | ||
| PropertyCopyLoop | 39,934,076.76 ns | 773,166.984 ns | 1,852,458.712 ns | 39,569,050.00 ns | 5400.0000 | 100.0000 | - | 23337248 B | | ||
| UserDefinedFunctions | 23,403,397.62 ns | 751,878.865 ns | 2,070,892.753 ns | 22,610,225.00 ns | 2156.2500 | 62.5000 | - | 9336567 B | | ||
| ResolvePolicyAliasPath | 2,284.19 ns | 70.184 ns | 197.956 ns | 2,275.12 ns | 0.2861 | - | - | 1200 B | | ||
| GetResourceType | 254.25 ns | 5.013 ns | 7.805 ns | 252.31 ns | 0.0858 | - | - | 360 B | | ||
| CustomTypeDependencyGraph_GetOrdered | 58.35 ns | 1.192 ns | 2.352 ns | 58.09 ns | 0.0401 | - | - | 168 B | |
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
48 changes: 48 additions & 0 deletions
48
tests/PSRule.Rules.Azure.Tests/CustomTypeTopologyGraphTests.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,48 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
using System.Linq; | ||
using Newtonsoft.Json.Linq; | ||
using PSRule.Rules.Azure.Data.Template; | ||
using Xunit; | ||
|
||
namespace PSRule.Rules.Azure; | ||
|
||
/// <summary> | ||
/// Tests for <see cref="CustomTypeTopologyGraph"/>. | ||
/// </summary> | ||
public sealed class CustomTypeTopologyGraphTests | ||
{ | ||
[Fact] | ||
public void Sort_custom_type_graph() | ||
{ | ||
var graph = new CustomTypeTopologyGraph(); | ||
graph.Add("base", GetObject()); | ||
graph.Add("nestedComplexType", GetObject("complexType")); | ||
graph.Add("basicType", GetObject("object")); | ||
graph.Add("object", GetObject()); | ||
graph.Add("array", GetObject("object")); | ||
graph.Add("complexType", GetObject("array")); | ||
graph.Add("newBase", GetObject()); | ||
|
||
var result = graph.GetOrdered().ToArray(); | ||
Assert.NotEmpty(result); | ||
|
||
Assert.Equal("#/definitions/base", result[0].Key); | ||
Assert.Equal("#/definitions/object", result[1].Key); | ||
Assert.Equal("#/definitions/array", result[2].Key); | ||
Assert.Equal("#/definitions/complexType", result[3].Key); | ||
Assert.Equal("#/definitions/nestedComplexType", result[4].Key); | ||
Assert.Equal("#/definitions/basicType", result[5].Key); | ||
Assert.Equal("#/definitions/newBase", result[6].Key); | ||
} | ||
|
||
#region Helper methods | ||
|
||
private static JObject GetObject(string ancestor = null) | ||
{ | ||
return ancestor == null ? new JObject() : JObject.Parse(string.Concat("{ \"$ref\": \"#/definitions/", ancestor, "\"}")); | ||
} | ||
|
||
#endregion Helper methods | ||
} |