-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
55 lines (47 loc) · 1.2 KB
/
Copy pathindex.js
File metadata and controls
55 lines (47 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { SQL } from "bun";
import { Pool } from "pg";
import postgres from 'postgres'
import { run, bench } from 'mitata';
const bun = new SQL({
max: 4,
hostname: "tfb-database",
port: 5432,
database: "hello_world",
username: "benchmarkdbuser",
password: "benchmarkdbpass",
max: 4, // Maximum connections in pool
idleTimeout: 30, // Close idle connections after 30s
maxLifetime: 0, // Connection lifetime in seconds (0 = forever)
connectionTimeout: 30, // Timeout when establishing new connections
tls: false,
});
const pg = new Pool({
max: 4,
host: 'tfb-database',
port: 5432,
database: 'hello_world',
user: 'benchmarkdbuser',
password: 'benchmarkdbpass',
});
const sql = postgres({
max: 4,
host: 'tfb-database',
port: 5432,
database: 'hello_world',
user: 'benchmarkdbuser',
password: 'benchmarkdbpass',
})
bench('bun', async () => {
await bun`SELECT id from Fortune`;
});
bench('postgres.js', async () => {
await sql`SELECT id from Fortune`;
});
bench('pg', async () => {
await pg.query({ text: `SELECT id from Fortune`, name: 'foo' });
});
await run({
format: 'mitata',
colors: true,
throw: true
});