Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > 2e9c43658e374d290a2de15d25134ac8 > files > 917

db4o-doc-8.0-1.fc15.i686.rpm

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="2" MadCap:lastHeight="120" MadCap:lastWidth="624" MadCap:disableMasterStylesheet="true" MadCap:tocPath="Tuning|Main Operations Performance|Update Performance" MadCap:InPreviewMode="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" MadCap:PathToHelpSystem="../../../../" MadCap:HelpSystemFileName="index.xml" MadCap:SearchType="Stem">
    <head><title>Object Structure	</title>
        <script type="text/javascript">/* <![CDATA[ */
window.onload = function(){
	var pathToFlash = $('html').attr('MadCap:PathToHelpSystem') + 'Content/Resources/Code/ZeroClipboard.swf';
	ZeroClipboard.setMoviePath(pathToFlash);
			
	function bindToClipBord(element,content){
		var clip = new ZeroClipboard.Client();
		clip.setText(content);
		clip.glue(element);
	};
		
	if(location.protocol==='file:'){
		$('.copylink-marker').remove();
	} else{
			$('.copylink-marker').each(function(){
				var text = $(this).parent().parent().children('.prettyprint').html();
				$(this).hover(function(){
					bindToClipBord(this,text);
				},
				function(){});
			});	
	}		
	prettyPrint();	
};
                /* ]]> */</script>
        <link href="../../../SkinSupport/MadCap.css" rel="stylesheet" />
        <link href="../../../Resources/Stylesheets/OnlineStyle.css" rel="stylesheet" />
        <script src="../../../Resources/Code/prettify.js">
        </script>
        <script src="../../../Resources/Code/lang-vb.js">
        </script>
        <script src="../../../Resources/Code/jquery.min.js">
        </script>
        <script src="../../../Resources/Code/ZeroClipboard.js">
        </script>
        <script src="../../../SkinSupport/MadCapAll.js" type="text/javascript">
        </script>
    </head>
    <body>
        <p class="MCWebHelpFramesetLink" style="display: none;"><a href="../../../../index_CSH.html#tuning/main_operations_performance/update_performance/object_structure.htm" style="">Open topic with navigation</a>
        </p>
        <div class="MCBreadcrumbsBox"><span class="MCBreadcrumbsPrefix">You are here: </span><a class="MCBreadcrumbsLink" href="../../../tuning.htm">Tuning</a><span class="MCBreadcrumbsDivider"> &gt; </span><a class="MCBreadcrumbsLink" href="../../main_operations_performance.htm">Main Operations Performance</a><span class="MCBreadcrumbsDivider"> &gt; </span><a class="MCBreadcrumbsLink" href="../update_performance.htm">Update Performance</a><span class="MCBreadcrumbsDivider"> &gt; </span><span class="MCBreadcrumbs">Object Structure</span>
        </div>
        <p>
            <script type="text/javascript">/*<![CDATA[*/document.write('<a href="' + location.href +'">');
				document.write("Direct Link");
			document.write('</a>');/*]]>*/</script>
        </p>
        <p>
        </p>
        <h1>Object Structure</h1>
        <p>
        </p>
        <p>Update performance is dependent upon the structure and
complexity of objects. This is demonstrated in the following test:</p>
        <p MadCap:conditions="Global.Primary:java" />
        <p MadCap:conditions="Primary..NET">
            <pre class="prettyprint" xml:space="preserve">UpdatePerformanceBenchmark.cs: RunDifferentObjectsTest
private void RunDifferentObjectsTest()
         {
            System.Console.WriteLine("Update test with different objects");
            int objectsToUpdate = 90;
            int updated = objectsToUpdate;

            InitDifferentObjectsTest();

            Clean();
            System.Console.WriteLine(" - primitive object with int field");
            Open(Configure());
            StoreSimplest();

            IObjectSet result = objectContainer.QueryByExample(null);
            StartTimer();
            for (int i = 0; i &lt; objectsToUpdate; i++)
             {
                if (result.HasNext())
                 {
                    SimplestItem item = (SimplestItem)result.Next();
                    item._id = 1;
                    Update(item);
                }
                else
                 {
                    updated = i;
                    break;
                }
            }
            StopTimer("Updated " + updated + " items");
            Close();

            Clean();
            Open(Configure());
            System.Console.WriteLine(" - object with string field");
            Store();
            updated = objectsToUpdate;
            result = objectContainer.QueryByExample(null);
            StartTimer();
            for (int i = 0; i &lt; objectsToUpdate; i++)
             {
                if (result.HasNext())
                 {
                    Item item = (Item)result.Next();
                    item._name = "Updated";
                    Update(item);
                }
                else
                 {
                    updated = i;
                    break;
                }
            }
            StopTimer("Updated " + updated + " items");
            Close();

            Clean();
            Open(Configure());
            System.Console.WriteLine(" - object with StringBuilder field");
            StoreWithStringBuilder();

            updated = objectsToUpdate;
            result = objectContainer.QueryByExample(null);
            StartTimer();
            for (int i = 0; i &lt; objectsToUpdate; i++)
             {
                if (result.HasNext())
                 {
                    ItemWithStringBuilder item = 
(ItemWithStringBuilder)result.Next();
                    item._name = new StringBuilder("Updated");
                    Update(item);
                }
                else
                 {
                    updated = i;
                    break;
                }
            }
            StopTimer("Updated " + updated + " items");
            Close();

            Clean();
            Open(Configure());
            System.Console.WriteLine(" - object with int array field");
            StoreWithArray();
            updated = objectsToUpdate;
            result = objectContainer.QueryByExample(null);
            StartTimer();
            for (int i = 0; i &lt; objectsToUpdate; i++)
             {
                if (result.HasNext())
                 {
                    ItemWithArray item = (ItemWithArray)result.Next();
                    item._id = new int[]  { 1, 2, 3 };
                    Update(item);
                }
                else
                 {
                    updated = i;
                    break;
                }
            }
            StopTimer("Updated " + updated + " items");
            Close();

            Clean();
            Open(Configure());
            System.Console.WriteLine(" - object with ArrayList field");
            StoreWithArrayList();
            updated = objectsToUpdate;
            result = objectContainer.QueryByExample(null);
            StartTimer();
            for (int i = 0; i &lt; objectsToUpdate; i++)
             {
                if (result.HasNext())
                 {
                    ItemWithArrayList item = (ItemWithArrayList)result.Next();
                    item._ids = new ArrayList();
                    Update(item);
                }
                else
                 {
                    updated = i;
                    break;
                }
            }
            StopTimer("Updated " + updated + " items");
            Close();
        }</pre>
            <pre class="prettyprint" xml:space="preserve">UpdatePerformanceBenchmark.cs: SimplestItem
public class SimplestItem
         {

            public int _id;
            public SimplestItem _child;

            public SimplestItem()
             {
            }

            public SimplestItem(int id, SimplestItem child)
             {
                _id = id;
                _child = child;
            }
        }</pre>
            <pre class="prettyprint" xml:space="preserve">UpdatePerformanceBenchmark.cs: ItemWithStringBuilder
public class ItemWithStringBuilder
         {

            public StringBuilder _name;
            public ItemWithStringBuilder _child;

            public ItemWithStringBuilder()
             {
            }

            public ItemWithStringBuilder(StringBuilder name, 
ItemWithStringBuilder child)
             {
                _name = name;
                _child = child;
            }
        }</pre>
            <pre class="prettyprint" xml:space="preserve">UpdatePerformanceBenchmark.cs: ItemWithArray
public class ItemWithArray
         {

            public int[] _id;
            public ItemWithArray _child;

            public ItemWithArray()
             {
            }

            public ItemWithArray(int[] id, ItemWithArray child)
             {
                _id = id;
                _child = child;
            }
        }</pre>
            <pre class="prettyprint" xml:space="preserve">UpdatePerformanceBenchmark.cs: ItemWithArrayList
public class ItemWithArrayList
         {

            public ArrayList _ids;
            public ItemWithArrayList _child;

            public ItemWithArrayList()
             {
            }

            public ItemWithArrayList(ArrayList ids, ItemWithArrayList child)
             {
                _ids = ids;
                _child = child;
            }
        }</pre>
        </p>
        <p MadCap:conditions="Global.Primary:net" />
        <p>The results:</p>
        <p><i>Update test with different objects</i>
        </p>
        <p><i> - primitive
object with int field</i>
        </p>
        <p><i>Store 1000 objects: 273ms</i>
        </p>
        <p><i>Updated 90 items: 185ms</i>
        </p>
        <p><i> - object with
String field</i>
        </p>
        <p><i>Store 1000 objects: 166ms</i>
        </p>
        <p><i>Updated 90 items: 158ms</i>
        </p>
        <p><i> - object with
StringBuffer field</i>
        </p>
        <p><i>Store 1000 objects: 199ms</i>
        </p>
        <p><i>Updated 90 items: 488ms</i>
        </p>
        <p><i> - object with
int array field</i>
        </p>
        <p><i>Store 1000 objects: 78ms</i>
        </p>
        <p><i>Updated 90 items: 134ms</i>
        </p>
        <p><i> - object with
ArrayList field</i>
        </p>
        <p><i>Store 1000 objects: 191ms</i>
        </p>
        <p><i>Updated 90 items: 647ms</i>
        </p>
        <p>In general update of a more complex object takes more time,
however the exact result depends on the TypeHandler implementation.</p>
        <p MadCap:conditions="Primary.Online">Download example code:</p>
        <p MadCap:conditions="Primary.Online">
            <MadCap:conditionalText MadCap:conditions="Primary..NET,Primary.c#,Primary.All languages"><a href="updateperformancecs.zip">c# </a>
            </MadCap:conditionalText>
        </p>
        <script type="text/javascript" src="../../../SkinSupport/MadCapBodyEnd.js">
        </script>
    </body>
</html>