{"id":20987445,"url":"https://github.com/stacks-archive/clarity-benchmarking","last_synced_at":"2025-05-14T17:34:07.334Z","repository":{"id":46120834,"uuid":"323762337","full_name":"stacks-network/clarity-benchmarking","owner":"stacks-network","description":null,"archived":false,"fork":false,"pushed_at":"2024-03-28T18:19:51.000Z","size":40191,"stargazers_count":1,"open_issues_count":1,"forks_count":5,"subscribers_count":13,"default_branch":"master","last_synced_at":"2024-04-14T11:50:54.567Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stacks-network.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2020-12-23T00:21:50.000Z","updated_at":"2024-04-14T11:50:54.568Z","dependencies_parsed_at":"2024-03-26T19:47:12.712Z","dependency_job_id":null,"html_url":"https://github.com/stacks-network/clarity-benchmarking","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":"stacks-network/.github","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stacks-network%2Fclarity-benchmarking","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stacks-network%2Fclarity-benchmarking/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stacks-network%2Fclarity-benchmarking/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stacks-network%2Fclarity-benchmarking/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stacks-network","download_url":"https://codeload.github.com/stacks-network/clarity-benchmarking/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225303940,"owners_count":17453037,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-19T06:16:58.991Z","updated_at":"2025-05-14T17:34:00.087Z","avatar_url":"https://github.com/stacks-network.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Clarity Native Function Benchmarking\nBenchmarking suite to determine constants for usage in the Clarity Cost Functions boot contract\n\n## Usage\n\n### Running the benchmark suite\n\nRunning the benchmarking suite can be done via the cargo `bench` command:\n\n```\ncargo bench\n```\n\nBenchmarking results will be outputted to the `target/criterion/` directory.\n\n\n### Running regression analysis\n\nOnce the benchmarking results have been collected, analysis scripts are\nused to compute regressions on the data, outputting estimated functions\nfor each cost function. These estimated functions have units of\n`nanoseconds per 100 executions` in the `y` dimension, and the input\nunit for the Clarity cost function in the `x` dimension.\n\nThe analysis script requires `SciPy`, so for convenience, a Dockerfile is\nincluded to perform analysis.\n\nVia docker:\n```\ndocker build -f analysis/analysis.Dockerfile --build-arg criterion_dir=\"latest-data/criterion\" -o /tmp/analysis-output/ .\n```\n\nThe `criterion_dir` optional argument tells the analysis script where in\nthe current directory to look for the benchmarking outputs. `latest-data`\nin this repository contains the data from the execution used to produce\nthe current proposal data.\n\nThis will output `cost_constants.csv` to `/tmp/analysis-output` and graphs\nof the analyzed data and regression.\n\n### Translating regression analysis into proposed costs\n\nOnce the regression is performed, the proposed cost functions need to\nscale those estimates into the correct dimensions for Clarity costs.\nThe runtime block limit in the Stacks network is `5e9` (unitless), and\nthe goal of the current proposal is that this should correspond to 30\nseconds or `3e10` nanoseconds. The `proposal/make_cost_functions.py`\nscript performs that scaling and formats output appropriate for a new\ncosts contract (i.e., Clarity language formatted) and for inclusion in\nmarkdown proposals (a markdown-formatted table).\n\nTo run this script:\n\n```\ncd ./proposal\ncp /tmp/analysis-output/cost_constants.csv ./estimated_constants.csv\npython ./make_cost_functions.py\n```\n\nThis will output to `new_costs.clar` and `updates_table.md`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstacks-archive%2Fclarity-benchmarking","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstacks-archive%2Fclarity-benchmarking","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstacks-archive%2Fclarity-benchmarking/lists"}