Created
August 26, 2015 18:54
-
-
Save glompix/8338c0602efe7c6804db to your computer and use it in GitHub Desktop.
Calculate average item size for a Sitecore database
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%@ Page language="c#" %> | |
<%@ Import Namespace="Sitecore.Data.Items" %> | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Cache Admin</title> | |
<link rel="shortcut icon" href="/sitecore/images/favicon.ico" /> | |
<% | |
var db = Sitecore.Configuration.Factory.GetDatabase("master"); | |
Func<Item[]> ReturnAllItems = () => | |
{ | |
Item i = db.GetItem("/sitecore/content"); | |
return i.Axes.GetDescendants(); | |
}; | |
var start = GC.GetTotalMemory(true); | |
var items = ReturnAllItems(); | |
var end = GC.GetTotalMemory(true); | |
var item = items[1]; // Supposedly required for accurate results. | |
const double bytesInKilo = 1024; | |
var bytesPerItem = (end - start) / (double)items.Length; | |
%> | |
</head> | |
<body> | |
<h1>Average Item Size Calculator</h1> | |
<p>This is a tool to determine what to set the <strong>Caching.AverageItemSize</strong> setting to.</p> | |
<p> | |
(<%= end %>B - <%= start %>B) / <%= items.Length %> items = <b><%= bytesPerItem %> B/item</b>. | |
</p> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment