Merge lp:~midori/midori/contrafile into lp:midori

Proposed by Cris Dywan
Status: Merged
Approved by: Paweł Forysiuk
Approved revision: 6602
Merged at revision: 6602
Proposed branch: lp:~midori/midori/contrafile
Merge into: lp:midori
Diff against target: 72 lines (+15/-11)
3 files modified
midori/midori-app.c (+1/-1)
midori/midori-bookmarks-db.c (+0/-10)
midori/midori-database.vala (+14/-0)
To merge this branch: bzr merge lp:~midori/midori/contrafile
Reviewer Review Type Date Requested Status
Paweł Forysiuk Approve
Review via email: mp+211220@code.launchpad.net

Commit message

Replace bookmark stracing with generic profiling in Midori.Database

To post a comment you must log in.
Revision history for this message
Paweł Forysiuk (tuxator) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'midori/midori-app.c'
2--- midori/midori-app.c 2014-03-05 18:43:15 +0000
3+++ midori/midori-app.c 2014-03-16 20:27:55 +0000
4@@ -1257,7 +1257,7 @@
5 midori_debug (const gchar* token)
6 {
7 static const gchar* debug_token = NULL;
8- const gchar* debug_tokens = "adblock:match adblock:parse adblock:time adblock:element startup headers body referer cookies paths hsts unarmed bookmarks mouse app ";
9+ const gchar* debug_tokens = "adblock:match adblock:parse adblock:time adblock:element startup headers body referer cookies paths hsts unarmed db:bookmarks db:history db:tabby mouse app database ";
10 if (debug_token == NULL)
11 {
12 gchar* found_token;
13
14=== modified file 'midori/midori-bookmarks-db.c'
15--- midori/midori-bookmarks-db.c 2014-01-24 23:04:05 +0000
16+++ midori/midori-bookmarks-db.c 2014-03-16 20:27:55 +0000
17@@ -683,13 +683,6 @@
18 katze_array_remove_item (KATZE_ARRAY (bookmarks), item);
19 }
20
21-static void
22-midori_bookmarks_db_dbtracer (void* dummy,
23- const char* query)
24-{
25- g_printerr ("%s\n", query);
26-}
27-
28 /**
29 * midori_bookmarks_db_new:
30 *
31@@ -721,9 +714,6 @@
32 db = midori_database_get_db (MIDORI_DATABASE (database));
33 g_return_val_if_fail (db != NULL, NULL);
34
35- if (midori_debug ("bookmarks"))
36- sqlite3_trace (db, midori_bookmarks_db_dbtracer, NULL);
37-
38 bookmarks = MIDORI_BOOKMARKS_DB (g_object_new (TYPE_MIDORI_BOOKMARKS_DB, NULL));
39 bookmarks->db = db;
40
41
42=== modified file 'midori/midori-database.vala'
43--- midori/midori-database.vala 2014-01-29 21:52:10 +0000
44+++ midori/midori-database.vala 2014-03-16 20:27:55 +0000
45@@ -128,6 +128,7 @@
46 * Since: 0.5.6
47 */
48 public class Database : GLib.Object, GLib.Initable {
49+ bool trace = false;
50 public Sqlite.Database? db { get { return _db; } }
51 protected Sqlite.Database? _db = null;
52 public string? path { get; protected set; default = null; }
53@@ -162,6 +163,19 @@
54 if (Sqlite.Database.open_v2 (real_path, out _db) != Sqlite.OK)
55 throw new DatabaseError.OPEN ("Failed to open database %s".printf (real_path));
56
57+ string token = Environment.get_variable ("MIDORI_DEBUG") ?? "";
58+ string basename = Path.get_basename (path);
59+ string[] parts = basename.split (".");
60+ trace = ("db:" + parts[0]) in token;
61+ if (trace) {
62+ stdout.printf ("§§ Tracing %s\n", path);
63+ db.profile ((sql, nanoseconds) => {
64+ /* sqlite as of this writing isn't more precise than ms */
65+ string milliseconds = (nanoseconds / 1000000).to_string ();
66+ stdout.printf ("§§ %s: %s (%sms)\n", path, sql, milliseconds);
67+ });
68+ }
69+
70 if (db.exec ("PRAGMA journal_mode = WAL; PRAGMA cache_size = 32100;") != Sqlite.OK)
71 db.exec ("PRAGMA synchronous = NORMAL; PRAGMA temp_store = MEMORY;");
72 db.exec ("PRAGMA count_changes = OFF;");

Subscribers

People subscribed via source and target branches

to all changes: