{"id":15653089,"url":"https://github.com/bwplotka/efficiency-coding-advent","last_synced_at":"2025-10-25T11:14:40.451Z","repository":{"id":79051029,"uuid":"434170041","full_name":"bwplotka/efficiency-coding-advent","owner":"bwplotka","description":null,"archived":false,"fork":false,"pushed_at":"2021-12-23T22:16:50.000Z","size":462,"stargazers_count":29,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-30T21:09:52.937Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bwplotka.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}},"created_at":"2021-12-02T10:08:17.000Z","updated_at":"2025-01-22T01:04:16.000Z","dependencies_parsed_at":"2024-01-20T04:14:36.856Z","dependency_job_id":"6e7cfb7e-5e9a-4162-9a7f-bfef92f20945","html_url":"https://github.com/bwplotka/efficiency-coding-advent","commit_stats":null,"previous_names":["bwplotka/efficiency-advent-2021"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bwplotka%2Fefficiency-coding-advent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bwplotka%2Fefficiency-coding-advent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bwplotka%2Fefficiency-coding-advent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bwplotka%2Fefficiency-coding-advent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bwplotka","download_url":"https://codeload.github.com/bwplotka/efficiency-coding-advent/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251782776,"owners_count":21642987,"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-10-03T12:44:39.935Z","updated_at":"2025-10-25T11:14:35.397Z","avatar_url":"https://github.com/bwplotka.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# efficiency-advent-2021\n\nRepo for [Advent of Code 2021](https://adventofcode.com/2021) in Go with efficient solutions. Note that I focus on \"maintainable\" efficiency. Imagine those algorithms are needed in critical path, but normal humans have to still be able to maintain it! (: \n\nYou will read more about tricks used here in [Efficient Go Book](https://www.oreilly.com/library/view/efficient-go/9781098105709/), but I left comments on various solutions through the challenges, enjoy! (: \n\nInspired by [Advent of Go Profiling 2021](https://felixge.de/2021/12/01/advent-of-go-profiling-2021-day-1-1/.)\n\nFollow others in their Advent of Code journey too!\n\n* [@felixge](https://felixge.de/2021/12/01/advent-of-go-profiling-2021-day-1-1/)\n* [@kabanek](https://twitter.com/kabanek/status/1466284532269821959)\n\n## How to Use this Repo\n\nEach day has two parts. Both are within the same `main.go` file within corresponding `dayXY` directory. You can find correctness tests and benchmarks within `main_test.go`\n\nBenchmark typically looks as follows:\n\n```go \nvar Answer int\n\nfunc BenchmarkFUNC_NAME(b *testing.B) {\n\tb.ReportAllocs()\n\tinput := strings.TrimSpace(day2.ReadTestInput(b)) + \"\\n\"\n\n\tb.ResetTimer()\n\tfor i := 0; i \u003c b.N; i++ {\n\t\tAnswer, _ = FUNC_NAME(input)\n\t}\n}\n```\n\nNotice the `Answer` var on global scope. This makes sure Go compiler will not optimize our function away.\n\nYou can run 5 tests, if you run command:\n\nYou can run this test by going into directory with this file and running:\n\n`export var=v1 \u0026\u0026 go test -count 5 -run '^$' -bench . -memprofile=${var}.mem.pprof -cpuprofile=${var}.cpu.pprof \u003e ${var}.txt`\n\nThis will give pprof profiles you can inspect by running:\n\n`go tool pprof -edgefraction=0 -functions -http=:8081 ${var}.cpu.pprof`\n\nor for memory:\n\n`go tool pprof -edgefraction=0 -functions -http=:8081 ${var}.mem.pprof`\n\nYou can also find output of benchmark using `benchstat` you can install using `go install golang.org/x/perf/cmd/benchstat`. This tool will get statistically correct value for multiple runs:\n\n`benchstat ${var}.txt`\n\nYou can also compare different results across each other e.g v1 and v5:\n\n`benchstat v1.txt v5.txt`\n\nThat's it! Enjoy (:\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbwplotka%2Fefficiency-coding-advent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbwplotka%2Fefficiency-coding-advent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbwplotka%2Fefficiency-coding-advent/lists"}