Skip to content

Commit 7d0a0b9

Browse files
authored
Improve benchmark cli, make compatible with deno (#4647)
# Description of Changes Now we get a `--help` for the benchmark, which is nicer. Also now can run under deno, with `deno --sloppy-imports -A src/demo.ts` (might be useful, deno's websocket is implemented in native code while node's is implemented in JS). I removed the [BOM](https://en.wikipedia.org/wiki/Byte_order_mark) because it seems unintentional (only found in `templates/keynote-2`) and was causing a little bit of weirdness. Also, fix the rust benchmark client as a follow-up to #4616 # Expected complexity level and risk 1 # Testing - [x] Works under deno and has usage
1 parent 05a4a7b commit 7d0a0b9

55 files changed

Lines changed: 524 additions & 315 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

pnpm-lock.yaml

Lines changed: 64 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

templates/keynote-2/bun/bun-server.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Pool } from 'pg';
1+
import { Pool } from 'pg';
22
import { drizzle } from 'drizzle-orm/node-postgres';
33
import { pgTable, integer, bigint as pgBigint } from 'drizzle-orm/pg-core';
44
import { eq, inArray, sql } from 'drizzle-orm';
@@ -110,7 +110,11 @@ async function rpcTransfer(args: Record<string, unknown>) {
110110
const toId = Number(args.to_id ?? args.to);
111111
const amount = Number(args.amount);
112112

113-
if (!Number.isInteger(fromId) || !Number.isInteger(toId) || !Number.isFinite(amount)) {
113+
if (
114+
!Number.isInteger(fromId) ||
115+
!Number.isInteger(toId) ||
116+
!Number.isFinite(amount)
117+
) {
114118
throw new Error('invalid transfer args');
115119
}
116120
if (fromId === toId || amount <= 0) return;
@@ -174,7 +178,6 @@ async function rpcGetAccount(args: Record<string, unknown>) {
174178
};
175179
}
176180

177-
178181
async function rpcVerify() {
179182
const rawInitial = process.env.SEED_INITIAL_BALANCE;
180183
if (!rawInitial) {

templates/keynote-2/convex-app/convex/accounts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { query } from "./_generated/server";
1+
import { query } from "./_generated/server";
22
import { v } from 'convex/values';
33

44
export const get_account = query(async ({ db }, { id }: { id: number }) => {

templates/keynote-2/convex-app/convex/balances.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// convex/balances.ts
1+
// convex/balances.ts
22
import { ShardedCounter } from '@convex-dev/sharded-counter';
33
import { components } from './_generated/api';
44

templates/keynote-2/convex-app/convex/convex.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { defineApp } from "convex/server";
1+
import { defineApp } from "convex/server";
22
import shardedCounter from "@convex-dev/sharded-counter/convex.config.js";
33

44
const app = defineApp();

templates/keynote-2/convex-app/convex/http.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { httpRouter } from "convex/server";
1+
import { httpRouter } from "convex/server";
22
import { httpAction } from "./_generated/server";
33
import { api } from "./_generated/api";
44
import { seed_range } from './seed';

templates/keynote-2/convex-app/convex/schema.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { defineSchema, defineTable } from "convex/server";
1+
import { defineSchema, defineTable } from "convex/server";
22
import { v } from "convex/values";
33

44
export default defineSchema({

templates/keynote-2/convex-app/convex/seed.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { v } from "convex/values";
1+
import { v } from "convex/values";
22
import { mutation } from "./_generated/server";
33

44
export const clear_accounts = mutation({

templates/keynote-2/convex-app/convex/transfer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { mutation } from "./_generated/server";
1+
import { mutation } from "./_generated/server";
22
import { v } from "convex/values";
33
import { accountBalances, accountKey } from './balances';
44

templates/keynote-2/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"@supabase/supabase-js": "^2.80.0",
3434
"better-sqlite3": "^12.4.1",
3535
"bun": "^1.3.2",
36+
"cac": "^7.0.0",
3637
"drizzle-orm": "^0.44.7",
3738
"express": "^5.1.0",
3839
"hdr-histogram-js": "^3.0.1",

0 commit comments

Comments
 (0)