Skip to content

Commit 6777768

Browse files
author
James William Pye
committed
Update to use new APIs.
1 parent ad4f3ec commit 6777768

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

postgresql/test/perf_query_io.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# copyright 2009, James William Pye
44
# http://python.projects.postgresql.org
55
##
6-
# Query I/O: Mass insert and select performance
6+
# Statement I/O: Mass insert and select performance
77
##
88
import os
99
import time
@@ -14,19 +14,19 @@ def insertSamples(count, insert_records):
1414
(-3, 123, 0xfffffea023, 'some_óäæ_thing', 'varying', 'æ')
1515
for x in range(count)
1616
]
17-
1817
gen = time.time()
19-
insert_records << recs
18+
insert_records.load(recs)
2019
fin = time.time()
2120
xacttime = fin - gen
2221
ats = count / xacttime
23-
print >>sys.stderr, \
22+
sys.stderr.write(
2423
"INSERT Summary,\n " \
2524
"inserted tuples: %d\n " \
2625
"total time: %f\n " \
2726
"average tuples per second: %f\n " %(
2827
count, xacttime, ats,
2928
)
29+
)
3030

3131
def timeTupleRead(portal):
3232
loops = 0
@@ -36,27 +36,28 @@ def timeTupleRead(portal):
3636
finalis = time.time()
3737
looptime = finalis - genesis
3838
ats = loops / looptime
39-
print >>sys.stderr, \
39+
sys.stderr.write(
4040
"SELECT Summary,\n " \
4141
"looped/tuples: %d\n " \
4242
"looptime: %f\n " \
4343
"average tuples per second: %f\n " %(loops, looptime, ats,)
44+
)
4445

4546
def main(count):
4647
execute('CREATE TEMP TABLE samples '
4748
'(i2 int2, i4 int4, i8 int8, t text, v varchar, c char)')
48-
insert_records = query(
49+
insert_records = prepare(
4950
"INSERT INTO samples VALUES ($1, $2, $3, $4, $5, $6)"
5051
)
51-
select_records = query("SELECT * FROM samples")
52+
select_records = prepare("SELECT * FROM samples")
5253
try:
5354
insertSamples(count, insert_records)
5455
timeTupleRead(select_records())
5556
finally:
5657
execute("DROP TABLE samples")
5758

5859
def command(args):
59-
main(int((args + [15000])[1]))
60+
main(int((args + [25000])[1]))
6061

6162
if __name__ == '__main__':
6263
command(sys.argv)

0 commit comments

Comments
 (0)