Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Glass test code
public void GetWholeDb()
var rawItem = _db.GetItem("/sitecore");
Item[] items = rawItem.Axes.GetDescendants();
var count = 0;
foreach (var item in items)
// Glass performs a version count to ensure we have a version in the language
if (item.Versions.Count > 0)
var value1 = rawItem["__DisplayName"];
var glassItem = _service.Cast<StubForWholeDb>(item);
if (glassItem != null)
var value2 = glassItem.DisplayName;
_rawTotal = _rawWatch.ElapsedTicks;
_glassTotal = _glassWatch.ElapsedTicks;
double total = _glassTotal / _rawTotal;
Console.WriteLine("Performance Test Count: {0} Ratio: {1} Average: {2}".Formatted(count, total, _glassTotal / count));
Console.WriteLine("Total Items {0}", count);
public class StubForWholeDb
public virtual Guid Id { get; set; }
public string Name { get; set; }
public string DisplayName { get; set; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.