1
1
const pg = require ( './lib' )
2
- const pool = new pg . Pool ( )
3
2
4
3
const params = {
5
4
text :
@@ -17,7 +16,7 @@ const seq = {
17
16
}
18
17
19
18
const exec = async ( client , q ) => {
20
- const result = await client . query ( {
19
+ await client . query ( {
21
20
text : q . text ,
22
21
values : q . values ,
23
22
rowMode : 'array' ,
@@ -39,7 +38,9 @@ const bench = async (client, q, time) => {
39
38
const run = async ( ) => {
40
39
const client = new pg . Client ( )
41
40
await client . connect ( )
41
+ console . log ( 'start' )
42
42
await client . query ( 'CREATE TEMP TABLE foobar(name TEXT, age NUMERIC)' )
43
+ await client . query ( 'CREATE TEMP TABLE buf(name TEXT, data BYTEA)' )
43
44
await bench ( client , params , 1000 )
44
45
console . log ( 'warmup done' )
45
46
const seconds = 5
@@ -61,7 +62,21 @@ const run = async () => {
61
62
console . log ( 'insert queries:' , queries )
62
63
console . log ( 'qps' , queries / seconds )
63
64
console . log ( 'on my laptop best so far seen 5799 qps' )
64
- console . log ( )
65
+
66
+ console . log ( '' )
67
+ console . log ( 'Warming up bytea test' )
68
+ await client . query ( {
69
+ text : 'INSERT INTO buf(name, data) VALUES ($1, $2)' ,
70
+ values : [ 'test' , Buffer . allocUnsafe ( 104857600 ) ] ,
71
+ } )
72
+ console . log ( 'bytea warmup done' )
73
+ const start = Date . now ( )
74
+ const results = await client . query ( 'SELECT * FROM buf' )
75
+ const time = Date . now ( ) - start
76
+ console . log ( 'bytea time:' , time , 'ms' )
77
+ console . log ( 'bytea length:' , results . rows [ 0 ] . data . byteLength , 'bytes' )
78
+ console . log ( 'on my laptop best so far seen 1107ms and 104857600 bytes' )
79
+
65
80
await client . end ( )
66
81
await client . end ( )
67
82
}
0 commit comments