Skip to content

Commit

Permalink
Added analyze script and initial calculations
Browse files Browse the repository at this point in the history
  • Loading branch information
aii23 committed May 31, 2024
1 parent bb441fe commit 71f7809
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 33 deletions.
9 changes: 9 additions & 0 deletions analyze_result.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Lottery_buyTicket": 31672,
"Lottery_produceResult": 10480,
"Lottery_refund": 40037,
"Lottery_getReward": 38242,
"Lottery_getCommisionForRound": 31404,
"DistributionProof_init": 145,
"DistibutionProof_addTicket": 8386
}
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"format": "prettier --write --ignore-unknown **/*",
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
"testw": "node --experimental-vm-modules node_modules/jest/bin/jest.js --watch",
"lint": "npx eslint src/* --fix"
"lint": "npx eslint src/* --fix",
"analyze": "npm run build && node build/scripts/analyze.js"
},
"devDependencies": {
"@babel/preset-env": "^7.16.4",
Expand All @@ -40,5 +41,8 @@
},
"engines": {
"node": ">=18.14.0"
},
"dependencies": {
"@types/node": "^20.12.13"
}
}
57 changes: 29 additions & 28 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 21 additions & 4 deletions scripts/analyze.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,25 @@
import { Lottery } from '../src/Lottery.js';
import { DistibutionProgram } from '../src/DistributionProof.js';
import { writeFileSync } from 'fs';

console.log(await Lottery.analyzeMethods());
console.log(await DistibutionProgram.analyzeMethods());
const lotteryResult = await Lottery.analyzeMethods();
const distributionResult = await DistibutionProgram.analyzeMethods();

// console.log(DistibutionProgram.analyzeMethods());
// console.log(Lottery.analyzeMethods());
if (!Lottery._methods) {
console.log("Can't find methods for Lottery");
throw new Error("Can't find methods for Lottery");
}

let result: { [name: string]: number } = {};

for (const method of Lottery._methods) {
result[`Lottery_${method.methodName}`] =
lotteryResult[method.methodName].rows;
}

result[`DistributionProof_init`] = distributionResult.init.rows;
result[`DistibutionProof_addTicket`] = distributionResult.addTicket.rows;

console.log(result);

writeFileSync('analyze_result.json', JSON.stringify(result, null, 2));

0 comments on commit 71f7809

Please sign in to comment.