diff scripts/performance-db.py @ 998:933670761a57

updated code to python 3 (tests pass and scripts run, but non-executed parts of code are probably still not correct)
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Sun, 27 May 2018 23:22:48 -0400
parents a850a4f92735
children cc5cb04b04b0
line wrap: on
line diff
--- a/scripts/performance-db.py	Fri May 25 18:15:18 2018 -0400
+++ b/scripts/performance-db.py	Sun May 27 23:22:48 2018 -0400
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
 
 import sys, shutil, os, sqlite3, timeit#, argparse
 
@@ -15,14 +15,14 @@
 connection = sqlite3.connect(dbFilename)
 
 nFeatures=storage.getNumberRowsTable(connection, "positions", "trajectory_id")
-print dbFilename, nFeatures
+print(dbFilename, nFeatures)
 
 ####
 # test query tmp trajectory instant table
 ####
 def selectTrajectoryIdInstant(connection, lastInstant):
     cursor = connection.cursor()
-    for i in xrange(lastInstant):
+    for i in range(lastInstant):
 	cursor.execute("select trajectory_id from trajectory_instants where last_instant = {}".format(lastInstant))
         cursor.fetchall()
 
@@ -44,7 +44,7 @@
 ####
 def selectTrajectories(connection, nFeatures):
     cursor = connection.cursor()
-    for i in xrange(nFeatures):
+    for i in range(nFeatures):
 	cursor.execute("select * from positions where trajectory_id = {} order by frame_number".format(i))
         cursor.fetchall()
 
@@ -66,7 +66,7 @@
     ####
     print("with index on trajectory_id")
     storage.createIndex(connection, "positions", "trajectory_id")#sqlite3 $dbFilename "create index trajectory_id_index on positions(trajectory_id)"
-    print timeit.timeit("selectTrajectories(connection, nFeatures)", setup="from __main__ import selectTrajectories, connection, nFeatures", number = 100)
+    print(timeit.timeit("selectTrajectories(connection, nFeatures)", setup="from __main__ import selectTrajectories, connection, nFeatures", number = 100))
 
 #### Cleanup
 os.remove(dbFilename)