{"id":20669024,"url":"https://github.com/guidanoli/gas-report-parser","last_synced_at":"2026-05-08T02:12:19.355Z","repository":{"id":67679019,"uuid":"597136042","full_name":"guidanoli/gas-report-parser","owner":"guidanoli","description":"Gas Reporter Parser","archived":false,"fork":false,"pushed_at":"2023-09-23T01:44:49.000Z","size":70,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-17T13:30:11.226Z","etag":null,"topics":["ethereum","forge","hardhat","lpeg","lua","parser"],"latest_commit_sha":null,"homepage":"","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/guidanoli.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-02-03T17:55:08.000Z","updated_at":"2023-02-05T00:48:38.000Z","dependencies_parsed_at":"2025-01-17T13:28:45.743Z","dependency_job_id":"38b737a6-93ee-4e59-ba70-325a0ff54cc2","html_url":"https://github.com/guidanoli/gas-report-parser","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guidanoli%2Fgas-report-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guidanoli%2Fgas-report-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guidanoli%2Fgas-report-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guidanoli%2Fgas-report-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/guidanoli","download_url":"https://codeload.github.com/guidanoli/gas-report-parser/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242883692,"owners_count":20200979,"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":["ethereum","forge","hardhat","lpeg","lua","parser"],"created_at":"2024-11-16T20:12:34.666Z","updated_at":"2026-05-08T02:12:14.334Z","avatar_url":"https://github.com/guidanoli.png","language":"Lua","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Gas Report Parser\n\nParses gas reports in different formats and outputs a Lua table in the same format. These Lua tables can be later used to produce diffs and other analysis.\n\n## Dependencies\n\n* [Lua](https://www.lua.org) 5.4\n* [LPEG](https://www.inf.puc-rio.br/~roberto/lpeg/) 1.0.2\n\n## Usage\n\n### Parsing gas reports\n\nOn the repository root, run the following command, where `\u003cfmt\u003e` is either `forge` or `hardhat`.\nIf this option is not provided, the tool tries to guess the format by running each parser.\n\n```sh\nlua main.lua parse [\u003cfmt\u003e]\n```\n\nThe program reads the gas report from the standard input and prints the Lua table to the standard output.\nYou can redirect these streams to files through operating system pipes.\n\n### Comparing gas reports\n\nYou can compare two gas reports that have been already parsed into Lua tables with the following command. Here, we don't need to discriminate the source of the gas report, since they all use the same Lua table scheme. Because we need two inputs, we cannot use standard input anymore. Instead, we need to read such Lua tables from files `\u003ca\u003e` and `\u003cb\u003e`.\n\n```sh\nlua main.lua diff \u003ca\u003e \u003cb\u003e\n```\n\nThe output of this program is another Lua table which computes the absolute difference (`b - a`) and the relative difference (`(b - a) / a`) of every entry. If the absolute difference is zero, it is discarded. Also, if a table gets empty because all of its entries were discarded, the table itself also gets discarded. This is simply to minimize the size of the output and to make the end result more conscise. After all, we are only interested in what were the gas costs changes.\n\n### Exporting diffs to Markdown tables\n\nIn the context of GitHub repositories, Markdown in the primary markup language. Because of this, we commonly format our tables using Markdown syntax. To make the process of exporting this information to Markdown simpler, you can run the following command.\n\n```sh\nlua main.lua printdiff\n```\n\nSimilar to `parse`, this program reads to `stdin` and writes to `stdout`.\n\n## Handy shell script\n\nIf you want to compare two gas reports quickly, you can use the following script.\n\n```sh\n./quickdiff.sh \u003ca\u003e \u003cb\u003e\n```\n\nWhere `\u003ca\u003e` and `\u003cb\u003e` are text files in either Forge or Hardhat format.\nThe tool tries to guess the format automatically.\n\n## Tests\n\nIf you want to see the program in action, you can simply run the `runtests.sh` Shell script. The test inputs and outputs are stored in the `test/` folder. If, after running such script, none of the files were change, it is a good sign that your program is working as expected on your machine.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguidanoli%2Fgas-report-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fguidanoli%2Fgas-report-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguidanoli%2Fgas-report-parser/lists"}