Do more quicker and better!

It is important that the ORM you choose to use performs well in a variety of different scenarios and doesn't put too much overhead on top of the native API. All ORMs will have some penalty but it is important that these be kept to a minimum while improving your development experience.

On this page you will find a variety of different tests that have been run as the page was loaded. This means that each time you refresh the page you will receive slightly different results. Each test is run under three different scenarios:
  1. Sitecore API - using the Sitecore API we use the code that you would need to use to get the equivalent Glass.Mapper.Sc result, e.g. making a field editable or converting to a specific .NET type.
  2. Glass Uncached - This is the performance you will get in the latest Glass.Mapper.Sc V3 and future V4 releases. The objects are being constructed on every request to Glass.Mapper.Sc.
  3. Glass Cached - This is a new feature coming in V4 and allows objects and entire graphs to be cached. Generally the object is only constructed on the first request and then always returned from the cache.

The results change each time the page is loaded and vary depending on what else is happening on the server. We would suggest that you refresh the page a few times to get a general idea of the performance results of each test in each scenario.

If you have any questions or comments about the performance results below please contact us.


Field Rendering

This first test compares how Glass performs against the native Sitecore API when rendering fields with Page Editor support. This test allows us to simulate the end-to-end process of rendering content to screen.

To make the Sitecore fields editable we use the Sitecore.Web.UI.WebControls.FieldRender.Render method, this method will called the RenderField pipeline behind the scenes which does the work of either returning the field value or adding Page Editor support. For Glass we are using the Editable, RenderLink and RenderImage methods, these are the methods you would normally use on your page to make properties editable.

For this test we are mapping the following fields:

  • Intro - Rich Text Field
  • __Updated - Date Time Field
  • LongTitle - Single Line Text Field
  • SiteLogo - Image Field
  • PurchaseLink - General Link Field

Sitecore

var item = db.GetItem(_path);
var text = FieldRenderer.Render(item, "Intro");
var date = FieldRenderer.Render(item, "__updated", "format=dd MMM yyyy");
var title = FieldRenderer.Render(item, "LongTitle");
var image = FieldRenderer.Render(item, "SiteLogo");
var link = FieldRenderer.Render(item, "PurchaseLink");
        

Glass

var glass = _context.GetItem<Test1Class>(_path);
var text = _glassHtml.Editable(glass, x=>x.Intro);
var date = _glassHtml.Editable(glass, x => x.Updated, glass.Updated.ToString("dd MMM yyyy"));
var title = _glassHtml.Editable(glass, x => x.LongTitle);
var image = _glassHtml.RenderImage(glass, x => x.SiteLogo);
var link = _glassHtml.RenderLink(glass, x => x.PurchaseLink);
        

Results:

Each test is run 10 times and the total time to run is shown below (less is better):

Method Time (Ticks) Ratio to SC API Milliseconds
Sitecore API 51640 NA 15
Glass Uncached 47417 0.92 13
Glass Cached 13051 0.25 3

Accessing Children

The second test builds on the first test but this time we loop through the child items. For each child item we map the following fields:

  • LongTitle - Single Line Text Field
  • Content - Rich Text Field
  • DisplayInMenu - Checkbox Field

We also map the child items URL. This

This test allows us to simulate a listing page and show the performance when we start to map a lot of items.

Sitecore

var item = db.GetItem(_path);
var text = FieldRenderer.Render(item, "Intro");
var date = FieldRenderer.Render(item, "__updated", "format=dd MMM yyyy");
var title = FieldRenderer.Render(item, "LongTitle");
var image = FieldRenderer.Render(item, "SiteLogo");
var link = FieldRenderer.Render(item, "PurchaseLink");

foreach (Item child in item.Children)
{
    if (child["DisplayInMenu"] == "1")
    {
        var childTitle = FieldRenderer.Render(child, "LongTitle");
        var childContent = FieldRenderer.Render(child, "Content");
        var childUrl = LinkManager.GetItemUrl(child);
    }
}
        

Glass

var glass = _context.GetItem<test2class>(_path);
var text = _glassHtml.Editable(glass, x => x.Intro);
var date = _glassHtml.Editable(glass, x => x.Updated, glass.Updated.ToString("dd MMM yyyy"));
var title = _glassHtml.Editable(glass, x => x.LongTitle);
var image = _glassHtml.RenderImage(glass, x => x.SiteLogo);
var link = _glassHtml.RenderLink(glass, x => x.PurchaseLink);

foreach (var child in glass.Children)
{
    if (child.DisplayInMenu)
    {
        var childTitle = _glassHtml.Editable(child, x => x.LongTitle);
        var childContent = _glassHtml.Editable(child, x => x.Content);
        var childUrl = child.Url;
    }
}
        

Results:

Each test is run 10 times and the total time to run is shown below (less is better). The number of children mapped was 10.

Method Time (Ticks) Ratio to SC API Milliseconds
Sitecore API 156392 NA 45
Glass Uncached 160317 1.03 46
Glass Cached 39367 0.25 11

Using Data In Code

This third test replicates follows the same format as the second test except that this time we aren't making any fields editable. Instead we are using code that you would typically use in your business logic. The code converts the field data into the appropriate .NET type and also makes sure that the data is in a format that can be used. For example we convert the __updated field into a System.DateTime and we ensure that the Intro field, which is Rich Text, has been processed correctly so that links and images are escaped correctly.

Sitecore

var item = db.GetItem(_path);
string title = item["LongTitle"];
string intro = FieldRenderer.Render(item, "Intro", "DisableWebEdit=true");
DateTime date = new DateField(item.Fields["__updated"]).DateTime;
string imageUrl = MediaManager.GetMediaUrl(new ImageField(item.Fields["SiteLogo"]).MediaItem);
string link = new LinkField(item.Fields["PurchaseLink"]).GetFriendlyUrl();

foreach (Item child in item.Children)
{
    string childTitle = child["LongTitle"];
    bool childCheck = new CheckboxField(child.Fields["DisplayInMenu"]).Checked;
    string childcontent = FieldRenderer.Render(child, "Content", "DisableWebEdit=true");
    string childUrl = LinkManager.GetItemUrl(child);
}
        

Glass

var glass = _context.GetItem<Test3Class>(_path);
string title = glass.LongTitle;
string intro = glass.Intro;
DateTime date = glass.Updated;
string imageUrl = glass.SiteLogo.Src;
string linkUrl = glass.PurchaseLink.Url;

foreach (var child in glass.Children)
{
    string childTitle = child.LongTitle;
    bool childChecked = child.DisplayInMenu;
    string childContent = child.Content;
    string childUrl = child.Url;
}
        

Results:

Each test is run 10 times and the total time to run is shown below (less is better). The number of children mapped was 10.

Method Time (Ticks) Ratio to SC API Milliseconds
Sitecore API 105360 NA 30
Glass Uncached 106993 1.02 31
Glass Cached 14472 0.14 4