From 44390b85f0540c209f08c38465f6a9f60bde90c5 Mon Sep 17 00:00:00 2001 From: igalklebanov Date: Wed, 8 Jan 2025 03:09:50 +0200 Subject: [PATCH] add knex (Kysely) benches. --- test/ts/selectFrom.bench.ts | 87 +++++++++++++++++++++++++++++-------- 1 file changed, 68 insertions(+), 19 deletions(-) diff --git a/test/ts/selectFrom.bench.ts b/test/ts/selectFrom.bench.ts index 68c1f2d93..4a2cf14cf 100644 --- a/test/ts/selectFrom.bench.ts +++ b/test/ts/selectFrom.bench.ts @@ -2,45 +2,94 @@ import { bench } from '@ark/attest' import type { DB } from '../typings/test-d/huge-db.test-d' import type { Kysely } from '../../src/index.js' -declare const db: Kysely +declare const kysely: Kysely +declare const knex: Kysely bench.baseline(() => {}) -bench('selectFrom(table)', () => { - return db.selectFrom('table_fff4c6195261874920bc7ce92d67d2c2') +bench('kysely.selectFrom(table)', () => { + return kysely.selectFrom('table_fff4c6195261874920bc7ce92d67d2c2') }).types([388, 'instantiations']) -bench('selectFrom(~table)', () => { - return db.selectFrom('my_table2') +bench('kysely.selectFrom(~table)', () => { + return kysely.selectFrom('my_table2') }).types([9314, 'instantiations']) -bench('selectFrom(table as alias)', () => { - return db.selectFrom('my_table as mt') +bench('kysely.selectFrom(table as alias)', () => { + return kysely.selectFrom('my_table as mt') }).types([401, 'instantiations']) -bench('selectFrom([table])', () => { - return db.selectFrom(['my_table']) +bench('kysely.selectFrom([table])', () => { + return kysely.selectFrom(['my_table']) }).types([413, 'instantiations']) -bench('selectFrom([~table])', () => { - return db.selectFrom(['my_table2']) +bench('kysely.selectFrom([~table])', () => { + return kysely.selectFrom(['my_table2']) }).types([9364, 'instantiations']) -bench('selectFrom([table as alias])', () => { - return db.selectFrom(['my_table as mt']) +bench('kysely.selectFrom([table as alias])', () => { + return kysely.selectFrom(['my_table as mt']) }).types([413, 'instantiations']) -bench('selectFrom([table, table])', () => { - return db.selectFrom(['my_table', 'table_000a8a0cb7f265a624c851d3e7f8b946']) +bench('kysely.selectFrom([table, table])', () => { + return kysely.selectFrom([ + 'my_table', + 'table_000a8a0cb7f265a624c851d3e7f8b946', + ]) }).types([413, 'instantiations']) -bench('selectFrom([table, ~table])', () => { - return db.selectFrom(['my_table', 'table_000a8a0cb7f265a624c851d3e7f8b9462']) +bench('kysely.selectFrom([table, ~table])', () => { + return kysely.selectFrom([ + 'my_table', + 'table_000a8a0cb7f265a624c851d3e7f8b9462', + ]) }).types([9367, 'instantiations']) -bench('selectFrom([table as alias, table as alias])', () => { - return db.selectFrom([ +bench('kysely.selectFrom([table as alias, table as alias])', () => { + return kysely.selectFrom([ 'my_table as mt', 'table_000a8a0cb7f265a624c851d3e7f8b946 as t', ]) }).types([413, 'instantiations']) + +bench('knex.selectFrom(table)', () => { + return knex.selectFrom('table_fff4c6195261874920bc7ce92d67d2c2') +}).types([140, 'instantiations']) + +bench('knex.selectFrom(~table)', () => { + return knex.selectFrom('my_table2') +}).types([140, 'instantiations']) + +bench('knex.selectFrom(table as alias)', () => { + return knex.selectFrom('my_table as mt') +}).types([140, 'instantiations']) + +bench('knex.selectFrom([table])', () => { + return knex.selectFrom(['my_table']) +}).types([165, 'instantiations']) + +bench('knex.selectFrom([~table])', () => { + return knex.selectFrom(['my_table2']) +}).types([165, 'instantiations']) + +bench('knex.selectFrom([table as alias])', () => { + return knex.selectFrom(['my_table as mt']) +}).types([165, 'instantiations']) + +bench('knex.selectFrom([table, table])', () => { + return knex.selectFrom(['my_table', 'table_000a8a0cb7f265a624c851d3e7f8b946']) +}).types([165, 'instantiations']) + +bench('knex.selectFrom([table, ~table])', () => { + return knex.selectFrom([ + 'my_table', + 'table_000a8a0cb7f265a624c851d3e7f8b9462', + ]) +}).types([165, 'instantiations']) + +bench('knex.selectFrom([table as alias, table as alias])', () => { + return knex.selectFrom([ + 'my_table as mt', + 'table_000a8a0cb7f265a624c851d3e7f8b946 as t', + ]) +}).types([165, 'instantiations'])