Ejemplo n.º 1
0
        private static void RunBenchmarksForDynamicPerson()
        {
            dynamic item = Person;

            var benchmarks = new List <Benchmark>
            {
                new Benchmark("Regextra Template w/FastMember", () => Template.Format(sampleNestedTemplate, item)),
                new Benchmark("SmartFormat.NET", () => Smart.Format(sampleNestedTemplate, item))
            };

            var group = new BenchmarkGroup("Dynamic Person Template", ITERATION_COUNT, benchmarks);

            group.Run();
        }
Ejemplo n.º 2
0
        public static void RunBenchmarksForExpandoObject()
        {
            dynamic item = new ExpandoObject();

            item.Id          = Person.Id;
            item.Name        = Person.Name;
            item.DateOfBirth = Person.DateOfBirth;

            var benchmarks = new List <Benchmark>
            {
                new Benchmark("Regextra Template", () => Template.Format(sampleTemplate, item)),
                new Benchmark("SmartFormat.NET", () => Smart.Format(sampleTemplate, item))
            };

            var group = new BenchmarkGroup("ExpandoObject Template", ITERATION_COUNT, benchmarks);

            group.Run();
        }
Ejemplo n.º 3
0
        private static void RunBenchmarksForNestedSampleTemplate()
        {
            var benchmarks = new List <Benchmark>
            {
                new Benchmark("Regextra Template w/FastMember", () => Template.Format(sampleNestedTemplate, Person)),
                new Benchmark("Regextra Template w/Reflection", () => TemplateReflection.Format(sampleNestedTemplate, Person)),
                new Benchmark("SmartFormat.NET", () => sampleNestedTemplate.FormatSmart(Person)),
                new Benchmark("SmartFormat.NET (Cached)", () =>
                {
                    SmartFormat.Core.FormatCache cache = null;
                    sampleNestedTemplate.FormatSmart(ref cache, Person);
                })
            };

            var group = new BenchmarkGroup("Nested Sample Template", ITERATION_COUNT, benchmarks);

            group.Run();
        }
Ejemplo n.º 4
0
        private static void RunBenchmarksForDictionaryInput()
        {
            var template = "The access code is {Code} and the token is {Token:N}.";
            var item     = new Dictionary <string, Guid>()
            {
                { "Code", Guid.NewGuid() },
                { "Token", Guid.NewGuid() }
            };

            var benchmarks = new List <Benchmark>
            {
                new Benchmark("Regextra Template", () => Template.Format(template, item)),
                new Benchmark("SmartFormat.NET", () => template.FormatSmart(item))
            };

            var group = new BenchmarkGroup("Dictionary Input Template", ITERATION_COUNT, benchmarks);

            group.Run();
        }