Skip to content

Instantly share code, notes, and snippets.

@mikeedwards83
Last active December 3, 2015 22:04
Show Gist options
  • Select an option

  • Save mikeedwards83/0f08bb59966b483e2076 to your computer and use it in GitHub Desktop.

Select an option

Save mikeedwards83/0f08bb59966b483e2076 to your computer and use it in GitHub Desktop.
Speed Test Code
service = new SitecoreContext();
var results = new Results();
Stopwatch watch3 = new Stopwatch();
watch3.Start();
for (int i = 0; i < 10000; i++)
{
var model = service.GetCurrentItem<Model>();
}
watch3.Stop();
results.GlassTicks = watch3.ElapsedTicks;
results.GlassMilli = watch3.ElapsedMilliseconds;
Stopwatch watch4 = new Stopwatch();
watch4.Start();
var factory = Global.Container.GetInstance<IItemFactory>();
for (int i = 0; i < 10000; i++)
{
var model = factory.GetContextItem<IPage>();
}
watch4.Stop();
results.FortisTicks = watch4.ElapsedTicks;
results.FortisMilli = watch4.ElapsedMilliseconds;
Stopwatch watch5 = new Stopwatch();
watch5.Start();
for (int i = 0; i < 10000; i++)
{
var model = service.GetCurrentItem<Model>();
var t1 = model.Text;
var t2 = model.Title;
var t3 = model.Link.Url;
var t4 = model.Id;
var t5 = model.Path;
}
watch5.Stop();
results.GlassTicks1 = watch5.ElapsedTicks;
results.GlassMilli1 = watch5.ElapsedMilliseconds;
Stopwatch watch6 = new Stopwatch();
watch6.Start();
for (int i = 0; i < 10000; i++)
{
var model = factory.GetContextItem<IPage>();
var t1 = model.Text.Value;
var t2 = model.Title.Value;
var t3 = model.Link.Url;
var t4 = model.ItemID;
var t5 = model.Path;
}
watch6.Stop();
results.FortisTicks1 = watch6.ElapsedTicks;
results.FortisMilli1 = watch6.ElapsedMilliseconds;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment