Beispiel #1
0
def doWithThreadSqlite(func):
    t = threading.Thread(target=lambda: bench.withSqliteConnection(
        "/tmp/test.db", func, isolationLevel=None, useWal=args["--wal"]))
    t.start()
    return t
Beispiel #2
0
                values (%s, %s, %s, %s, CURRENT_TIMESTAMP)
                """,
                [aid, "user%08d" %i, "first%08d" %i, "last%08d" %i]
            )

    def performInsert():
        cur = conn.cursor()
        insertAddress(cur)
        bulkUpdate(
            conn, (lambda cur: None), lambda cur: conn.commit(), insertFunc
        )

    def performSelect():
        cur = conn.cursor()
        cur.execute(
            "prepare myquery as "
            "select count(*) from users u inner join addresses a on u.address_id = a.address_id where address = $1"
        )
        for i in range(1, 500):
            cur.execute("execute myquery (%s)", (address[i % len(address)],))
            cur.fetchall()
            
    bench.createTablePgsql(conn)
    bench.withStopwatch("insert departments with Postgres", performInsert)
    bench.withStopwatch("select departments with Postgres", performSelect)

if __name__ == '__main__':
    args = docopt(__doc__)
    bench.withSqliteConnection("/tmp/test.db", selectBenchSqlite, isolationLevel = None, useWal = args["--wal"])
    bench.withPgsqlConnection(selectBenchPgsql)