Skip to content
This repository was archived by the owner on Dec 13, 2021. It is now read-only.

Commit 44e86f8

Browse files
committed
Performance Tests - Attempting to reduce a Ditto call to its minimum
By registering a default empty processor (and context accessor), and de-registering all the post-processor types. Once we can establish the performance of a "bare minimum" Ditto mapping, we can start to identify issues with specific processors.
1 parent 6dbf878 commit 44e86f8

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

tests/Our.Umbraco.Ditto.PerformanceTests/PublishedContentMapping.cs

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using Our.Umbraco.Ditto.Tests.Mocks;
33
using Umbraco.Core;
44
using Umbraco.Core.Models;
5+
using Umbraco.Web;
56

67
namespace Our.Umbraco.Ditto.PerformanceTests
78
{
@@ -19,6 +20,17 @@ public class BasicModel
1920

2021
private IPublishedContent content;
2122

23+
public class NullContextAccessor : IDittoContextAccessor
24+
{
25+
public UmbracoContext UmbracoContext => default(UmbracoContext);
26+
public ApplicationContext ApplicationContext => default(ApplicationContext);
27+
}
28+
29+
public class NullProcessorAttribute : DittoProcessorAttribute
30+
{
31+
public override object ProcessValue() { return null; }
32+
}
33+
2234
[GlobalSetup]
2335
public void Setup()
2436
{
@@ -28,16 +40,24 @@ public void Setup()
2840
Name = "MyCustomName",
2941
Properties = new[] { new MockPublishedContentProperty("item", "myValue") }
3042
};
43+
44+
// Try running at a complete minimum, strip back everything
45+
Ditto.RegisterContextAccessor<NullContextAccessor>();
46+
Ditto.RegisterDefaultProcessorType<NullProcessorAttribute>();
47+
Ditto.DeregisterPostProcessorType<HtmlStringAttribute>();
48+
Ditto.DeregisterPostProcessorType<EnumerableConverterAttribute>();
49+
Ditto.DeregisterPostProcessorType<RecursiveDittoAttribute>();
50+
Ditto.DeregisterPostProcessorType<TryConvertToAttribute>();
3151
}
3252

3353
[Benchmark(Baseline = true)]
3454
public void MapManually()
3555
{
3656
new BasicModel
3757
{
38-
Id = this.content.Id,
39-
Name = this.content.Name,
40-
Item = this.content.GetProperty("item").Value.TryConvertTo<string>().Result
58+
Id = default(int), // this.content.Id,
59+
Name = default(string), // this.content.Name,
60+
Item = default(string), // this.content.GetProperty("item").Value.TryConvertTo<string>().Result
4161
};
4262
}
4363

0 commit comments

Comments
 (0)