diff --git a/benchmark/base-benchmark.ts b/benchmark/benchmark.ts similarity index 94% rename from benchmark/base-benchmark.ts rename to benchmark/benchmark.ts index 6571915bf9..17ae0d9816 100644 --- a/benchmark/base-benchmark.ts +++ b/benchmark/benchmark.ts @@ -115,9 +115,7 @@ function logResult( console.log(result.label + `\n`); console.log(`time: ${resultToString(result)}`); - if (!previousResult) { - return; - } + if (previousResult === undefined) return; let change = (result.mean - previousResult.mean) / previousResult.mean; let p = pValue(result, previousResult); @@ -167,8 +165,8 @@ function pValue(sample1: BenchmarkResult, sample2: BenchmarkResult): number { } function calculateBounds(result: BenchmarkResult) { - const percentage = (Math.sqrt(result.variance) / result.mean) * 100; - const upperBound = result.mean + (result.mean * percentage) / 100; - const lowerBound = result.mean - (result.mean * percentage) / 100; + const stdDev = Math.sqrt(result.variance); + const upperBound = result.mean + stdDev; + const lowerBound = result.mean - stdDev; return { upperBound, lowerBound }; } diff --git a/benchmark/samples/ecdsa.ts b/benchmark/benchmarks/ecdsa.ts similarity index 93% rename from benchmark/samples/ecdsa.ts rename to benchmark/benchmarks/ecdsa.ts index a11c9c9047..28de1c4544 100644 --- a/benchmark/samples/ecdsa.ts +++ b/benchmark/benchmarks/ecdsa.ts @@ -1,5 +1,5 @@ /** - * ECDSA benchmark sample + * ECDSA benchmark */ import { Provable } from 'o1js'; @@ -9,7 +9,7 @@ import { Secp256k1, keccakAndEcdsa, } from '../../src/examples/crypto/ecdsa/ecdsa.js'; -import { benchmark } from '../base-benchmark.js'; +import { benchmark } from '../benchmark.js'; let privateKey = Secp256k1.Scalar.random(); let publicKey = Secp256k1.generator.scale(privateKey); diff --git a/benchmark/runners/simple.ts b/benchmark/runners/simple.ts index 8706439e77..4d447a4c81 100644 --- a/benchmark/runners/simple.ts +++ b/benchmark/runners/simple.ts @@ -8,8 +8,8 @@ * ``` */ -import { logResult } from '../base-benchmark.js'; -import EcdsaBenchmark from '../samples/ecdsa.js'; +import { logResult } from '../benchmark.js'; +import EcdsaBenchmark from '../benchmarks/ecdsa.js'; // Run all benchmarks const results = [...(await EcdsaBenchmark.run())]; diff --git a/benchmark/runners/with-cloud-history.ts b/benchmark/runners/with-cloud-history.ts index 273c987e48..463a3c61b3 100644 --- a/benchmark/runners/with-cloud-history.ts +++ b/benchmark/runners/with-cloud-history.ts @@ -7,8 +7,8 @@ * ``` */ -import { logResult } from '../base-benchmark.js'; -import EcdsaBenchmark from '../samples/ecdsa.js'; +import { logResult } from '../benchmark.js'; +import EcdsaBenchmark from '../benchmarks/ecdsa.js'; import { readPreviousResultFromInfluxDb, writeResultToInfluxDb, diff --git a/benchmark/utils/influxdb-utils.ts b/benchmark/utils/influxdb-utils.ts index 07d63f9aa2..089d39a2dd 100644 --- a/benchmark/utils/influxdb-utils.ts +++ b/benchmark/utils/influxdb-utils.ts @@ -4,7 +4,7 @@ import { InfluxDB, Point } from '@influxdata/influxdb-client'; import os from 'node:os'; -import { BenchmarkResult, calculateBounds } from '../base-benchmark.js'; +import { BenchmarkResult, calculateBounds } from '../benchmark.js'; const INFLUXDB_CLIENT_OPTIONS = { url: process.env.INFLUXDB_URL, diff --git a/package-lock.json b/package-lock.json index f3d5c413f3..e94b7fdc43 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,6 @@ "version": "0.17.0", "license": "Apache-2.0", "dependencies": { - "@influxdata/influxdb-client": "^1.33.2", "blakejs": "1.2.1", "cachedir": "^2.4.0", "isomorphic-fetch": "^3.0.0", @@ -21,6 +20,7 @@ "snarky-run": "src/build/run.js" }, "devDependencies": { + "@influxdata/influxdb-client": "^1.33.2", "@noble/hashes": "^1.3.2", "@playwright/test": "^1.25.2", "@types/isomorphic-fetch": "^0.0.36", @@ -819,7 +819,8 @@ "node_modules/@influxdata/influxdb-client": { "version": "1.33.2", "resolved": "https://registry.npmjs.org/@influxdata/influxdb-client/-/influxdb-client-1.33.2.tgz", - "integrity": "sha512-RT5SxH+grHAazo/YK3UTuWK/frPWRM0N7vkrCUyqVprDgQzlLP+bSK4ak2Jv3QVF/pazTnsxWjvtKZdwskV5Xw==" + "integrity": "sha512-RT5SxH+grHAazo/YK3UTuWK/frPWRM0N7vkrCUyqVprDgQzlLP+bSK4ak2Jv3QVF/pazTnsxWjvtKZdwskV5Xw==", + "dev": true }, "node_modules/@istanbuljs/load-nyc-config": { "version": "1.1.0", diff --git a/package.json b/package.json index b32ebaded2..93fdc88923 100644 --- a/package.json +++ b/package.json @@ -69,6 +69,7 @@ }, "author": "O(1) Labs", "devDependencies": { + "@influxdata/influxdb-client": "^1.33.2", "@noble/hashes": "^1.3.2", "@playwright/test": "^1.25.2", "@types/isomorphic-fetch": "^0.0.36", @@ -94,7 +95,6 @@ "typescript": "5.1" }, "dependencies": { - "@influxdata/influxdb-client": "^1.33.2", "blakejs": "1.2.1", "cachedir": "^2.4.0", "isomorphic-fetch": "^3.0.0",