[chronojump] Better SQL stress tests
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Better SQL stress tests
- Date: Tue, 28 Jul 2015 10:35:08 +0000 (UTC)
commit 8e4686a19832fa2ec326e361060031823dafb0dd
Author: Xavier de Blas <xaviblas gmail com>
Date: Tue Jul 28 12:28:48 2015 +0200
Better SQL stress tests
glade/chronojump.glade | 94 +++++++++++++++++++++++++++++++++++++++++++-----
src/gui/chronojump.cs | 38 +++++++++++++++++---
src/sqlite/main.cs | 20 ++++++----
3 files changed, 130 insertions(+), 22 deletions(-)
---
diff --git a/glade/chronojump.glade b/glade/chronojump.glade
index 897f85c..a2fcb7f 100644
--- a/glade/chronojump.glade
+++ b/glade/chronojump.glade
@@ -452,21 +452,37 @@
</widget>
</child>
<child>
- <widget class="GtkMenuItem" id="menuitem_SQL_stress_test_short">
+ <widget class="GtkMenuItem" id="menuitem_SQL_stress_test_safe_short">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="label" translatable="yes">SQL stress test short</property>
+ <property name="label">SQL stress test SAFE short</property>
<property name="use_underline">True</property>
- <signal name="activate" handler="on_menuitem_SQL_stress_test_short_activate"
swapped="no"/>
+ <signal name="activate" handler="on_menuitem_SQL_stress_test_safe_short_activate"
swapped="no"/>
</widget>
</child>
<child>
- <widget class="GtkMenuItem" id="menuitem_SQL_stress_test_long">
+ <widget class="GtkMenuItem" id="menuitem_SQL_stress_test_safe_long">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="label" translatable="yes">SQL stress test long</property>
+ <property name="label">SQL stress test SAFE long</property>
<property name="use_underline">True</property>
- <signal name="activate" handler="on_menuitem_SQL_stress_test_long_activate"
swapped="no"/>
+ <signal name="activate" handler="on_menuitem_SQL_stress_test_safe_long_activate"
swapped="no"/>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkMenuItem" id="menuitem_SQL_stress_test_not_safe_short">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label">SQL stress test NOT SAFE short</property>
+ <signal name="activate"
handler="on_menuitem_SQL_stress_test_not_safe_short_activate" swapped="no"/>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkMenuItem" id="menuitem_SQL_stress_test_not_safe_long">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label">SQL stress test NOT SAFE long</property>
+ <signal name="activate" handler="on_menuitem_SQL_stress_test_not_safe_long_activate"
swapped="no"/>
</widget>
</child>
</widget>
@@ -7613,6 +7629,9 @@ after time</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
<child>
@@ -8997,6 +9016,9 @@ after time</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="position">2</property>
@@ -10022,6 +10044,9 @@ after time</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="position">4</property>
@@ -21500,6 +21525,9 @@ by you</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
@@ -22424,6 +22452,9 @@ by you</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
@@ -23840,6 +23871,9 @@ by you</property>
<placeholder/>
</child>
<child>
+ <placeholder/>
+ </child>
+ <child>
<widget class="GtkButton" id="button_video_url">
<property name="visible">True</property>
<property name="can_focus">True</property>
@@ -24313,6 +24347,9 @@ by you</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="expand">True</property>
@@ -35636,6 +35673,24 @@ options</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
@@ -37295,6 +37350,18 @@ To differentiate between male and female, use the values 1/0, or m/f, or M/F on
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
@@ -38671,9 +38738,6 @@ To differentiate between male and female, use the values 1/0, or m/f, or M/F on
<placeholder/>
</child>
<child>
- <placeholder/>
- </child>
- <child>
<widget class="GtkLabel" id="label218">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -39597,6 +39661,9 @@ To differentiate between male and female, use the values 1/0, or m/f, or M/F on
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
@@ -43308,6 +43375,9 @@ It starts before and arrives there with some speed.</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="left_attach">2</property>
@@ -43896,6 +43966,9 @@ It starts before and arrives there with some speed.</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
@@ -44499,6 +44572,9 @@ It starts before and arrives there with some speed.</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index d670050..7b5e20a 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -32,7 +32,8 @@ using LongoMatch.Gui;
using LongoMatch.Video.Capturer;
using LongoMatch.Video.Common;
using LongoMatch.Video.Utils;
-//using System.Diagnostics;
+
+using System.Diagnostics; //StopWatch
public partial class ChronoJumpWindow
{
@@ -6212,22 +6213,49 @@ LogB.Debug("X");
*/
}
- private void on_menuitem_SQL_stress_test_short_activate (object o, EventArgs args) {
+ // ---- start SQL stress tests ---->
+
+ private void on_menuitem_SQL_stress_test_safe_short_activate (object o, EventArgs args) {
+ LogB.Information("start safe short stress test ---->");
+ sql_stress_test(1000);
+ }
+ private void on_menuitem_SQL_stress_test_safe_long_activate (object o, EventArgs args) {
+ LogB.Information("start safe long stress test ---->");
+ sql_stress_test(4000);
+ }
+ private void on_menuitem_SQL_stress_test_not_safe_short_activate (object o, EventArgs args) {
+ LogB.Information("start not safe short stress test ---->");
+ Sqlite.SafeClose = false;
sql_stress_test(1000);
+ Sqlite.SafeClose = true;
}
- private void on_menuitem_SQL_stress_test_long_activate (object o, EventArgs args) {
+ private void on_menuitem_SQL_stress_test_not_safe_long_activate (object o, EventArgs args) {
+ LogB.Information("start not safe long stress test ---->");
+ Sqlite.SafeClose = false;
sql_stress_test(4000);
+ Sqlite.SafeClose = true;
}
private void sql_stress_test (int times) {
+ Stopwatch sw = new Stopwatch();
+
+ sw.Start();
+
//trying if new way of Sqlite.Close disposing dbcmd fixes problems when multiple open / close
connection
for(int i=0 ; i < times; i++) {
LogB.Debug (" i=" + i.ToString());
LogB.Debug(SqlitePreferences.Select("databaseVersion"));
}
-
- new DialogMessage(Constants.MessageTypes.INFO, "SQL test successfull!" + "\n\n" + "Done " +
times + " times.");
+ sw.Stop();
+
+ string message = "SQL test successfull!" + "\n\n" +
+ "Done " + times + " times." + "\n\n" +
+ "Elapsed " + sw.ElapsedMilliseconds + " milliseconds.";
+ LogB.Information(message);
+ new DialogMessage(Constants.MessageTypes.INFO, message);
}
+ // <---- end SQL stress tests ----
+
private void on_about1_activate (object o, EventArgs args) {
string translator_credits = Catalog.GetString ("translator-credits");
diff --git a/src/sqlite/main.cs b/src/sqlite/main.cs
index c1ee5a3..68e0533 100644
--- a/src/sqlite/main.cs
+++ b/src/sqlite/main.cs
@@ -72,6 +72,7 @@ class Sqlite
protected static int conversionSubRateTotal;
public static bool IsOpened = false;
+ public static bool SafeClose = true;
/*
* Important, change this if there's any update to database
@@ -100,11 +101,7 @@ class Sqlite
} catch {
LogB.SQL("-- catched --");
- LogB.SQLoff();
- dbcmd.Dispose(); //this seems critical in multiple open/close SQL
- dbcon.Close();
- GC.Collect();
- dbcmd = dbcon.CreateCommand();
+ Close();
LogB.Warning(" going to open ");
LogB.SQLon();
@@ -118,10 +115,17 @@ class Sqlite
public static void Close()
{
LogB.SQLoff();
- dbcmd.Dispose(); //this seems critical in multiple open/close SQL
+
+ if(SafeClose) {
+ dbcmd.Dispose(); //this seems critical in multiple open/close SQL
+ }
+
dbcon.Close();
- GC.Collect();
- dbcmd = dbcon.CreateCommand();
+
+ if(SafeClose) {
+ //GC.Collect(); don't need and very slow
+ dbcmd = dbcon.CreateCommand();
+ }
IsOpened = false;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]