Skip to content

Commit

Permalink
fix bench script
Browse files Browse the repository at this point in the history
  • Loading branch information
kyscott18 committed Nov 14, 2023
1 parent e35659c commit 0015812
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 46 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
uses: ./.github/actions/setup

- name: Bench
run: pnpm bench:ponder-ci
run: pnpm bench:ponder:ci
env:
ANVIL_FORK_URL: ${{ secrets.ANVIL_FORK_URL }}
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/postgres
2 changes: 1 addition & 1 deletion benchmarks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"private": true,
"scripts": {
"bench:ponder": "export $(grep -v '^#' .env.local | xargs) && rm -rf data/ && docker-compose up --detach && tsup-node && (node dist/ponder.mjs || true) && docker-compose down",
"bench:ponder-ci": "tsup-node && node dist/ponder.mjs"
"bench:ponder:ci": "tsup-node && node dist/ponder.mjs"
},
"devDependencies": {
"@graphprotocol/graph-cli": "0.54.0-alpha-20230727052453-1e0e6e5",
Expand Down
40 changes: 0 additions & 40 deletions benchmarks/src/bench.ts

This file was deleted.

32 changes: 31 additions & 1 deletion benchmarks/src/subgraph.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { readFileSync, writeFileSync } from "node:fs";

import { execa } from "execa";
import parsePrometheusTextFormat from "parse-prometheus-text-format";

Expand Down Expand Up @@ -104,7 +106,7 @@ const waitForSyncComplete = async () => {
return duration;
};

export const subgraph = async () => {
const subgraph = async () => {
console.log(`Waiting for Graph Node to be ready...`);
const setupDuration = await waitForGraphNode();

Expand Down Expand Up @@ -140,3 +142,31 @@ export const subgraph = async () => {

return { setupDuration, duration };
};

const changeMappingFileDelim = (delim: string) => {
let mappingFileContents = readFileSync("./subgraph/src/mapping.ts", {
encoding: "utf-8",
});
mappingFileContents = mappingFileContents.replace(
/(kevin:.)/g,
`kevin:${delim}`,
);

writeFileSync("./subgraph/src/mapping.ts", mappingFileContents, "utf-8");
};

const bench = async () => {
// Reset handler delimeter
changeMappingFileDelim("-");

const subgraphCold = await subgraph();

// Force handler cache invalidation
changeMappingFileDelim("+");

const subgraphHot = await subgraph();

console.log({ subgraphCold, subgraphHot });
};

await bench();
2 changes: 1 addition & 1 deletion benchmarks/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { defineConfig } from "tsup";

export default defineConfig({
entry: ["src/ponder.ts"],
entry: ["src/ponder.ts", "src/subgraph.ts"],
bundle: true,
format: ["esm"],
sourcemap: false,
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"private": true,
"scripts": {
"bench": "pnpm --filter \"./benchmarks\" bench",
"bench:ci": "pnpm --filter \"./benchmarks\" bench:ci",
"bench:ponder": "pnpm --filter \"./benchmarks\" bench:ponder",
"bench:ponder:ci:": "pnpm --filter \"./benchmarks\" bench:ponder:ci",
"build": "pnpm --filter \"@ponder/core\" build && pnpm --filter \"./packages/*\" --filter \"!@ponder/core\" --parallel build",
"changeset:release": "pnpm build && changeset publish",
"changeset:version": "changeset version && pnpm install --lockfile-only",
Expand Down

0 comments on commit 0015812

Please sign in to comment.