MCPcopy
hub / github.com/electric-sql/pglite / runPostgres

Function runPostgres

packages/benchmark/baseline.ts:71–98  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

69}
70
71async function runPostgres() {
72 console.log('Postgres')
73
74 const pg = new EmbeddedPostgres({
75 databaseDir: './pgdata',
76 user: 'postgres',
77 password: 'password',
78 port: 5439,
79 persistent: false,
80 })
81 console.log(pg)
82 await pg.initialise()
83 await pg.start()
84 const client = pg.getPgClient()
85 await client.connect()
86
87 for (const [i, [id, b]] of benchmarks.entries()) {
88 const startTime = Date.now()
89 await client.query(b)
90 const elapsed = (Date.now() - startTime) / 1000
91 console.log(`Test ${id}: ${elapsed}ms`)
92 results[i].postgres = elapsed
93 }
94
95 await client.end()
96
97 await pg.stop()
98}
99
100function resultsTable() {
101 const table = new AsciiTable3('Benchmark Results')

Callers 1

mainFunction · 0.85

Calls 4

stopMethod · 0.80
queryMethod · 0.65
logMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected