Skip to content

Instantly share code, notes, and snippets.

@kamsar
Created June 11, 2015 13:30
Show Gist options
  • Select an option

  • Save kamsar/f2aa92ef3f63f3c7b931 to your computer and use it in GitHub Desktop.

Select an option

Save kamsar/f2aa92ef3f63f3c7b931 to your computer and use it in GitHub Desktop.

Revisions

  1. kamsar created this gist Jun 11, 2015.
    20 changes: 20 additions & 0 deletions Benchmark.cs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    var items = Sitecore.Context.Database.GetRootItem().Axes.GetDescendants();

    Response.Write("<h1>{0} Items</h1>".FormatWith(items.Length));

    var sw = new Stopwatch();
    sw.Start();

    var displayNamesScapi = items.Select(item => item[FieldIDs.DisplayName]).ToList();

    sw.Stop();

    Response.Write("<h1>SCAPI {0}ms</h1>".FormatWith(sw.ElapsedMilliseconds));

    sw.Restart();

    var displayNamesSynthesis = items.AsStronglyTypedCollection().Select(x => x.DisplayName).ToList();

    sw.Stop();

    Response.Write("<h1>Synthesis {0}ms</h1>".FormatWith(sw.ElapsedMilliseconds));
    5 changes: 5 additions & 0 deletions Results.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    5148 Items

    SCAPI 20ms

    Synthesis 57ms