Hello,
I've tried to evaluate the performance of SQlite.net with the following code and db structure. Maybe someone can try it out because I only have an emulator to test it. In my opinion the execution is quite slow.
16 seconds for 1000 records to insert. Maybe I have to adjust my code to get more performance
//SqlitePerformnace Test public SqliteDBPerformanceTest(Context context) {
//Table structure:
//[PrimaryKey, AutoIncrement]
//public int ID{ get; set; }
//public string Ident{ get; set; }
//public string Description{ get; set; }
//public string State{ get; set; }
//public string Lecturer{ get; set; }
string dbPath = Path.Combine(
System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal),
"test.db");
if (File.Exists(dbPath))
File.Delete(dbPath);
_connection = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.XamarinAndroid.SQLitePlatformAndroid(), dbPath, SQLite.Net.Interop.SQLiteOpenFlags.Create | SQLite.Net.Interop.SQLiteOpenFlags.ReadWrite | SQLite.Net.Interop.SQLiteOpenFlags.SharedCache | SQLite.Net.Interop.SQLiteOpenFlags.NoMutex | SQLite.Net.Interop.SQLiteOpenFlags.ProtectionNone);
_connection.Execute("PRAGMA synchronous = OFF");
_connection.CreateTable<Course>();
}
public void Run()
{
SQLiteCommand cmd = _connection.CreateCommand("Insert Into courses (Ident, Description, State, Lecturer) Values(@p1, @p2, @p3, @p4)");
DateTime now = DateTime.Now;
_connection.BeginTransaction();
for (int i = 0; i < 1000; i++)
{
cmd.Bind("@p1", Guid.NewGuid().ToString());
cmd.Bind("@p2", "It seems to be very slow");
cmd.Bind("@p3", "public");
cmd.Bind("@p4", "Kevin Tough");
cmd.ExecuteNonQuery();
}
_connection.Commit();
_executionTime = DateTime.Now - now;
List<Course> crs = _connection.Query<Course>("Select * From courses");
this.Count = crs.Count.ToString();
}