Phantom said:
Its the amount of objects within the Hasthtable that takes the most tme, saving is nothing.
I respect your ideas Phantom, but if that were the case, then why would my tests show different?
I added as I stated before, 2 million items. These were put in the hashtable like all other items. I then saved, and it 'looped' through the m_Items.Values and checked to see if the variable CheckSaveItem was true or false. If false, it went to the next item, otherwise, it did normal save. If I put 2 million of the exact same items (minus the override CheckSaveItem) in my normal server and saved, it would take around 20 seconds to save.
Here is what I am using:
(Control)
Code:
using System;
using System.Collections;
using Server.Items;
namespace Server.FeudalSystem
{
public class TestControl : Item
{
ArrayList TestArray;
[Constructable]
public TestControl() : base( 3804 )
{
TestArray = new ArrayList();
}
public override void OnDoubleClick( Mobile from )
{
if( TestArray == null )
TestArray = new ArrayList();
int xx = Location.X;
int yy = Location.Y;
int zz = Location.Z;
for( int x = 0; x < 1000; x++ )
{
for( int y = 0; y < 1000; y++ )
{
TestTest ti = new TestTest( 147 );
ti.MoveToWorld( new Point3D( xx+x, yy+y, zz ), Map );
TestArray.Add( ti );
}
}
}
public TestControl( Serial serial ) : base( serial )
{
}
public override void Serialize( GenericWriter writer )
{
writer.Write( (int) 0 ); // version
base.Serialize( writer );
writer.Write( TestArray.Count );
for( int i = 0; i < TestArray.Count; i++ )
{
writer.Write( ((TestTest)TestArray[i]).Location );
}
Console.WriteLine( "Number of Items : {0}", World.Items.Count );
}
public override void Deserialize( GenericReader reader )
{
int version = reader.ReadInt();
base.Deserialize( reader );
int count = reader.ReadInt();
for( int i = 0; i < count; i++ )
{
TestTest tt = new TestTest( 147 );
tt.MoveToWorld( reader.ReadPoint3D(), Map );
}
}
}
}
(TestItem)
Code:
using System;
using System.Collections;
using Server.Items;
namespace Server.FeudalSystem
{
public class TestTest : Item
{
//public override bool CheckSaveItem{ get{ return false; } }
[Constructable]
public TestTest( int id ) : base( id )
{
}
public TestTest( Serial serial ) : base( serial )
{
}
public override void Serialize( GenericWriter writer )
{
//Console.WriteLine( "Serialize Test" );
base.Serialize( writer );
writer.Write( (int) 0 ); // version
}
public override void Deserialize( GenericReader reader )
{
//Console.WriteLine( "DeSerialize Test" );
base.Deserialize( reader );
int version = reader.ReadInt();
}
}
}
With 1 dclick of the Control on a normal server, a save is 10.9 seconds. (World.Items.Count = 1000037 )
With 1 dclick of the Control on my modified server, a save is .9 seconds. (World.Items.Count = 1000037 )
So, I therefore have to completely disagree with you on your point. The size of the Hashtable has very little to do with the time of the saves. It effects it, yes, but not to the degree of noticeability. HDD's are a LOT slower than processors, so the saving to the HDD is the slow part. (Or all of the calculations after my CheckSaveItem termination, but I don't think even those calcs are going to effect the time of saves, but I could be wrong)
*Works on figuring out how to get the world to load*