1
Vote

Performance

description

Hello

I use Sterling in WP8 project. I have made some tests and DB has low performance. I saved 1000 very simple objects, which contained only id and type fields, this operation lasted 5 seconds.

Could you tell me If I wasdoing something wrong ?

//Entity
public class CustomerTypeSterling : BaseModel<CustomerTypeSterling>
{
    public String Type { get; set; }
}

//---------------Context Class
public class SterlingContext : IDisposable
{
    public ISterlingDatabaseInstance DB { get; set; }
    private SterlingEngine engine;

    public SterlingContext()
    {
        this.engine = new SterlingEngine();
        this.engine.Activate();
        this.DB = engine.SterlingDatabase.RegisterDatabase<SterlingDatabase>(new IsolatedStorageDriver());
        this.RegisterTriggers();
    }

    private void RegisterTriggers()
    {
        DB.RegisterTrigger<CustomerTypeSterling, int>(new IdentityTrigger<CustomerTypeSterling>(DB));
        DB.RegisterTrigger<CustomerSterling, int>(new IdentityTrigger<CustomerSterling>(DB));
        DB.RegisterTrigger<ConversationHeaderSterling, int>(new IdentityTrigger<ConversationHeaderSterling>(DB));
        DB.RegisterTrigger<ProductSterling, int>(new IdentityTrigger<ProductSterling>(DB));
        DB.RegisterTrigger<AttachmentsSterling, int>(new IdentityTrigger<AttachmentsSterling>(DB));
        DB.RegisterTrigger<CustomerProductSterling, int>(new IdentityTrigger<CustomerProductSterling>(DB));
    }

    public void Dispose()
    {
        engine.Dispose();
        DB = null;
        engine = null;
    }

    private class SterlingDatabase : BaseDatabaseInstance
    {
        protected override List<ITableDefinition> RegisterTables()
        {
            return new List<ITableDefinition>()
            {
                CreateTableDefinition<CustomerTypeSterling, int>(x => x.Id),
                CreateTableDefinition<CustomerSterling,int>(x => x.Id),
                CreateTableDefinition<ConversationHeaderSterling,int>(x => x.Id),
                CreateTableDefinition<ProductSterling,int>(x => x.Id),
                CreateTableDefinition<CustomerProductSterling,int>(x => x.Id),
                CreateTableDefinition<AttachmentsSterling,int>(x => x.Id),
            };
        }
    }
}
//-----------Usage
using (var db = new SterlingContext())
        {
            for (int i = 0; i < 1000; i++)
            {

                db.DB.Save<CustomerTypeSterling>(new CustomerTypeSterling());
            }
        }

comments