Download:
child 61:16a9800b0bf3
parent 59:e78ae7d3a395
60:39064bc2bcb4
Anton Shestakov <av6@dwimlabs.net>, Mon, 04 Jul 2016 18:06:48 +0800
bench: split long lines of SQL

1 файлов изменено, 18 вставок(+), 8 удалений(-) [+]
bench.py file | annotate | diff | comparison | revisions
--- a/bench.py Mon Jul 04 17:52:42 2016 +0800
+++ b/bench.py Mon Jul 04 18:06:48 2016 +0800
@@ -97,7 +97,10 @@
conn = sqlite3.connect(DBPATH)
while len(todo) < maxrevs:
node = nodes.pop()
- count = conn.execute('SELECT COUNT(*) FROM results WHERE node = ?', (node,)).fetchone()[0]
+ count = conn.execute(
+ 'SELECT COUNT(*) FROM results'
+ ' WHERE node = ?',
+ (node,)).fetchone()[0]
if count < len(MARKS) * len(('without cache', 'with cache')):
todo.append(node)
picking = True
@@ -116,11 +119,13 @@
limits = {
mark:
conn.execute(
- 'SELECT MIN(time), MAX(time) FROM results WHERE mark = ? AND cache = ?',
+ 'SELECT MIN(time), MAX(time) FROM results'
+ ' WHERE mark = ? AND cache = ?',
(mark, False)).fetchone()
+
conn.execute(
- 'SELECT MIN(time), MAX(time) FROM results WHERE mark = ? AND cache = ?',
+ 'SELECT MIN(time), MAX(time) FROM results'
+ ' WHERE mark = ? AND cache = ?',
(mark, True)).fetchone()
for mark in MARKS
}
@@ -175,9 +180,11 @@
' cache BOOL NOT NULL'
')')
conn.execute(
- 'CREATE INDEX IF NOT EXISTS idx_results_node ON results (node)')
+ 'CREATE INDEX IF NOT EXISTS idx_results_node'
+ ' ON results (node)')
conn.execute(
- 'CREATE INDEX IF NOT EXISTS idx_results_limits ON results (mark, cache, node, time ASC)')
+ 'CREATE INDEX IF NOT EXISTS idx_results_limits'
+ ' ON results (mark, cache, node, time ASC)')
conn.commit()
conn.close()
@@ -195,7 +202,8 @@
for mark in MARKS:
for cache in (False, True):
old = conn.execute(
- 'SELECT time FROM results WHERE node = ? AND mark = ? AND cache = ?',
+ 'SELECT time FROM results'
+ ' WHERE node = ? AND mark = ? AND cache = ?',
(node, mark, cache)).fetchall()
oldtime = old[0][0] if old else None
@@ -224,11 +232,13 @@
if oldtime is None:
conn.execute(
- 'INSERT INTO results (node, mark, time, cache) VALUES (?, ?, ?, ?)',
+ 'INSERT INTO results (node, mark, time, cache)'
+ ' VALUES (?, ?, ?, ?)',
(node, mark, time, cache))
elif time < oldtime:
conn.execute(
- 'UPDATE results SET time = ? WHERE node = ? AND mark = ? AND cache = ?',
+ 'UPDATE results SET time = ?'
+ ' WHERE node = ? AND mark = ? AND cache = ?',
(time, node, mark, cache))
conn.commit()