-
-
Notifications
You must be signed in to change notification settings - Fork 180
/
LiquidNetBenchmarks.cs
40 lines (34 loc) · 1.16 KB
/
LiquidNetBenchmarks.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using Liquid.NET;
using Liquid.NET.Utils;
namespace Fluid.Benchmarks
{
public class LiquidNetBenchmarks : BaseBenchmarks
{
private readonly LiquidParsingResult _liquidNetTemplate;
public LiquidNetBenchmarks()
{
_liquidNetTemplate = LiquidTemplate.Create(ProductTemplate);
}
public override object Parse()
{
return LiquidTemplate.Create(ProductTemplate);
}
public override object ParseBig()
{
return LiquidTemplate.Create(BlogPostTemplate);
}
public override string Render()
{
var context = new Liquid.NET.TemplateContext();
context.DefineLocalVariable("products", Products.ToLiquid());
return _liquidNetTemplate.LiquidTemplate.Render(context).Result;
}
public override string ParseAndRender()
{
var template = LiquidTemplate.Create(ProductTemplate);
var context = new Liquid.NET.TemplateContext();
context.DefineLocalVariable("products", Products.ToLiquid());
return template.LiquidTemplate.Render(context).Result;
}
}
}