{"id":16833794,"url":"https://github.com/mvdan/benchinit","last_synced_at":"2025-04-09T17:25:58.677Z","repository":{"id":57480817,"uuid":"164902796","full_name":"mvdan/benchinit","owner":"mvdan","description":"Benchmark the init cost of Go packages","archived":false,"fork":false,"pushed_at":"2025-02-11T23:23:28.000Z","size":99,"stargazers_count":76,"open_issues_count":0,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-02T11:57:47.799Z","etag":null,"topics":["benchmark","cost","go","init","initialization","performance"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mvdan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":"mvdan"}},"created_at":"2019-01-09T16:56:11.000Z","updated_at":"2025-02-18T21:35:57.000Z","dependencies_parsed_at":"2025-03-16T16:20:42.361Z","dependency_job_id":null,"html_url":"https://github.com/mvdan/benchinit","commit_stats":{"total_commits":81,"total_committers":2,"mean_commits":40.5,"dds":"0.012345679012345734","last_synced_commit":"4abb552e8a87f15cfa5bb441bdb5b9fdda04c11e"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mvdan%2Fbenchinit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mvdan%2Fbenchinit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mvdan%2Fbenchinit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mvdan%2Fbenchinit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mvdan","download_url":"https://codeload.github.com/mvdan/benchinit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248076045,"owners_count":21043698,"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":["benchmark","cost","go","init","initialization","performance"],"created_at":"2024-10-13T11:55:17.696Z","updated_at":"2025-04-09T17:25:58.654Z","avatar_url":"https://github.com/mvdan.png","language":"Go","readme":"# benchinit\n\nBenchmark the initialization cost of your packages or programs.\nRequires Go 1.23 or later.\n\n\tgo install mvdan.cc/benchinit@latest\n\nThis includes the cost of `init` functions and initialising globals.\nIn other words, a package's contribution to the slowness before `main` is run.\n\n### Quickstart\n\nBenchmarking a single package is simple:\n\n\tbenchinit cmd/go\n\nYou can benchmark multiple packages too; there must be at most one main package:\n\n\tbenchinit cmd/go go/parser go/build\n\nYou can also include all dependencies in the benchmark:\n\n\tbenchinit -r cmd/go\n\nFinally, like any other benchmark, you can pass in `go test` flags:\n\n\tbenchinit -r -count=5 -benchtime=2s cmd/go\n\n### Further reading\n\nThe original tool was result of a discussion with [@josharian](https://github.com/josharian).\nYou can read more about Josh's idea in his [blog post](https://commaok.xyz/post/benchmark-init/).\nSince then, `GODEBUG=inittrace=1` was [added in Go 1.16](https://go.dev/doc/go1.16#runtime),\nwhich this tool now uses.\n\nThe following design decisions were made:\n\n* `GODEBUG=inittrace=1` requires us to run a new Go process for every benchmark\n  iteration, so `benchinit` sets up a wrapping benchmark `BenchmarkInit` which\n  does this and collects the `inittrace` output. `BenchmarkInit` then produces\n  one `BenchmarkPkgPath` result per package passed to `benchinit`, which is\n  shown to the user.\n\n* `benchinit` supports most build and test flags, which are passed down as\n  needed. For example, you can use `-benchtime` and `-count` to control how the\n  benchmark is run, and `-tags` to use build tags. Note that some test flags\n  like `-bench` aren't supported, as we always run only `BenchmarkInit`.\n\n* To avoid building a new binary, `BenchmarkInit` reuses its own test binary to\n  run the Go process for each benchmark iteration. To prevent test globals and\n  `init` funcs from being part of the result, all `*_test.go` files are masked\n  as deleted via `-overlay`. The same overlay is used to insert a temporary file\n  containing `BenchmarkInit`.\n\n* `BenchmarkInit` only runs one Go process per benchmark iteration, even when\n  benchmarking multiple packages at once. This is possible since `inittrace`\n  prints one line per package being initialized, so we only need to ensure\n  the test binary imports all the necessary packages to initialize them.\n  For the same reason, we can only benchmark one `main` package at a time.\n\n* If none of the given packages are a `main` package, the benchmark is run from\n  the first given package. This helps us support benchmarking internal packages.\n","funding_links":["https://github.com/sponsors/mvdan"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmvdan%2Fbenchinit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmvdan%2Fbenchinit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmvdan%2Fbenchinit/lists"}