| 69 | } |
| 70 | |
| 71 | async 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 | |
| 100 | function resultsTable() { |
| 101 | const table = new AsciiTable3('Benchmark Results') |