@alejoamiras/aztec-benchmark 0.0.0-canary.gb8d1485

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,61 @@
1
+ import * as os from 'node:os';
2
+ /**
3
+ * Gets the effective CPU count, respecting container limits.
4
+ * Uses availableParallelism() which is cgroup-aware in Node 18.14+/19.4+
5
+ */
6
+ function getEffectiveCpuCount() {
7
+ if (typeof os.availableParallelism === 'function') {
8
+ return os.availableParallelism();
9
+ }
10
+ return os.cpus().length;
11
+ }
12
+ /**
13
+ * Gets total system memory in GiB.
14
+ */
15
+ function getTotalMemoryGiB() {
16
+ return Math.round(os.totalmem() / (1024 * 1024 * 1024));
17
+ }
18
+ /**
19
+ * Collects system information for benchmark reports.
20
+ * Returns N/A values if information cannot be determined.
21
+ */
22
+ export function getSystemInfo() {
23
+ let cpuModel = 'N/A';
24
+ let cpuCores = 0;
25
+ let totalMemoryGiB = 0;
26
+ let arch = 'N/A';
27
+ try {
28
+ cpuCores = getEffectiveCpuCount();
29
+ }
30
+ catch {
31
+ // Keep default 0
32
+ }
33
+ try {
34
+ totalMemoryGiB = getTotalMemoryGiB();
35
+ }
36
+ catch {
37
+ // Keep default 0
38
+ }
39
+ try {
40
+ // Prefer RUNNER_ARCH env var in CI environments
41
+ arch = (process.env.RUNNER_ARCH ?? os.arch()).toLowerCase();
42
+ }
43
+ catch {
44
+ // Keep default N/A
45
+ }
46
+ try {
47
+ const cpus = os.cpus();
48
+ if (cpus && cpus.length > 0 && cpus[0]?.model) {
49
+ cpuModel = cpus[0].model.trim();
50
+ }
51
+ }
52
+ catch {
53
+ // Keep default N/A
54
+ }
55
+ return {
56
+ cpuModel,
57
+ cpuCores,
58
+ totalMemoryGiB,
59
+ arch,
60
+ };
61
+ }
@@ -0,0 +1,79 @@
1
+ import type { AztecAddress } from '@aztec/aztec.js/addresses';
2
+ import type { ContractFunctionInteractionCallIntent } from '@aztec/aztec.js/authorization';
3
+ import type { FeePaymentMethod } from '@aztec/aztec.js/fee';
4
+ import type { EmbeddedWallet } from '@aztec/wallets/embedded';
5
+ import type { SystemInfo } from './systemInfo.js';
6
+ export type { SystemInfo } from './systemInfo.js';
7
+ /** Simplified Gas type (contains actual gas values) */
8
+ export type Gas = {
9
+ /** Data Availability gas */
10
+ daGas: number;
11
+ /** Layer 2 execution gas */
12
+ l2Gas: number;
13
+ };
14
+ /** Structure holding execution and teardown gas */
15
+ export type GasLimits = {
16
+ gasLimits: Gas;
17
+ teardownGasLimits: Gas;
18
+ };
19
+ /** Benchmark specific setup/teardown context */
20
+ export interface BenchmarkContext {
21
+ wallet?: EmbeddedWallet;
22
+ /** Optional fee payment method used when sending profiled transactions.
23
+ * When set, the profiler passes this to every send/prove call.
24
+ * When unset, the sender must have pre-existing Fee Juice. */
25
+ feePaymentMethod?: FeePaymentMethod;
26
+ }
27
+ /** Gate counts for a specific circuit */
28
+ export interface GateCount {
29
+ /** The name of the circuit. */
30
+ circuitName: string;
31
+ /** The number of gates in the circuit. */
32
+ gateCount: number;
33
+ /** Witness generation time in ms (hardware-dependent). */
34
+ witgenMs?: number;
35
+ }
36
+ /** Result of profiling a single function */
37
+ export interface ProfileResult {
38
+ /** The name of the profiled function. */
39
+ name: string;
40
+ /** The total gate count for the function. */
41
+ totalGateCount: number;
42
+ /** Detailed gate counts for each circuit in the function. */
43
+ gateCounts: GateCount[];
44
+ /** Gas usage information for the function. */
45
+ gas?: GasLimits;
46
+ /** Proving time in milliseconds. */
47
+ provingTime?: number;
48
+ }
49
+ /** Defines a contract interaction to be benchmarked, with a custom display name. */
50
+ export interface NamedBenchmarkedInteraction {
51
+ /** The contract function interaction from Aztec.js. */
52
+ interaction: ContractFunctionInteractionCallIntent;
53
+ /** The custom name to be used for this benchmark in reports. */
54
+ name: string;
55
+ /** Extra addresses whose private state (keys, notes) should be accessible during execution. */
56
+ additionalScopes?: AztecAddress[];
57
+ }
58
+ /** Structure of the output JSON report */
59
+ export interface ProfileReport {
60
+ /** Total gate counts keyed by function name */
61
+ summary: Record<string, number>;
62
+ /** Detailed results for each function */
63
+ results: ProfileResult[];
64
+ /** Gas summary (total L2 + DA) keyed by function name */
65
+ gasSummary: Record<string, number>;
66
+ /** Proving time summary (in ms) keyed by function name */
67
+ provingTimeSummary: Record<string, number>;
68
+ /** System information where the benchmark was run */
69
+ systemInfo: SystemInfo;
70
+ }
71
+ /** Abstract class for users to extend */
72
+ export declare abstract class BenchmarkBase {
73
+ /** Optional setup function run before benchmarks */
74
+ abstract setup?(): Promise<BenchmarkContext>;
75
+ /** Function returning the methods to benchmark. Can be a mix of plain interactions or named interactions. */
76
+ abstract getMethods(context: BenchmarkContext): Array<ContractFunctionInteractionCallIntent | NamedBenchmarkedInteraction>;
77
+ /** Optional teardown function run after benchmarks (no longer abstract) */
78
+ teardown?(context: BenchmarkContext): Promise<void>;
79
+ }
package/dist/types.js ADDED
@@ -0,0 +1,3 @@
1
+ /** Abstract class for users to extend */
2
+ export class BenchmarkBase {
3
+ }
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@alejoamiras/aztec-benchmark",
3
+ "version": "0.0.0-canary.gb8d1485",
4
+ "description": "CLI tool and GitHub Action for Aztec contract benchmarking",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/alejoamiras/ecosystem-tooling.git",
8
+ "directory": "packages/aztec-benchmark"
9
+ },
10
+ "license": "MIT",
11
+ "type": "module",
12
+ "main": "dist/index.js",
13
+ "types": "dist/index.d.ts",
14
+ "bin": {
15
+ "aztec-benchmark": "bin/aztec-benchmark"
16
+ },
17
+ "files": [
18
+ "dist",
19
+ "action",
20
+ "bin",
21
+ "README.md",
22
+ "LICENSE"
23
+ ],
24
+ "scripts": {
25
+ "build": "tsc && ncc build action/index.cjs -o action/dist -m -C",
26
+ "start": "tsx cli/cli.ts"
27
+ },
28
+ "dependencies": {
29
+ "@actions/core": "1.10.1",
30
+ "@actions/exec": "1.1.1",
31
+ "@iarna/toml": "2.2.5",
32
+ "commander": "13.1.0",
33
+ "esbuild": "0.25.0",
34
+ "tsx": "4.19.4",
35
+ "typescript": "5.8.3"
36
+ },
37
+ "devDependencies": {
38
+ "@aztec/aztec.js": "5.0.0-rc.2",
39
+ "@aztec/stdlib": "5.0.0-rc.2",
40
+ "@aztec/wallets": "5.0.0-rc.2",
41
+ "@types/node": "22.15.3",
42
+ "@vercel/ncc": "0.38.3"
43
+ },
44
+ "peerDependencies": {
45
+ "@aztec/aztec.js": "5.0.0-rc.2",
46
+ "@aztec/wallets": "5.0.0-rc.2"
47
+ },
48
+ "engines": {
49
+ "node": ">=22"
50
+ },
51
+ "publishConfig": {
52
+ "access": "public"
53
+ }
54
+ }