{"id":19381241,"url":"https://github.com/probably-not/pow","last_synced_at":"2026-06-08T23:04:24.139Z","repository":{"id":61627692,"uuid":"404609602","full_name":"probably-not/pow","owner":"probably-not","description":"Some games in powers of 2","archived":false,"fork":false,"pushed_at":"2021-09-12T06:47:33.000Z","size":16,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-24T16:53:21.842Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/probably-not.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null}},"created_at":"2021-09-09T06:23:15.000Z","updated_at":"2021-09-12T06:47:35.000Z","dependencies_parsed_at":"2022-10-19T19:00:44.314Z","dependency_job_id":null,"html_url":"https://github.com/probably-not/pow","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/probably-not/pow","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/probably-not%2Fpow","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/probably-not%2Fpow/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/probably-not%2Fpow/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/probably-not%2Fpow/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/probably-not","download_url":"https://codeload.github.com/probably-not/pow/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/probably-not%2Fpow/sbom","scorecard":{"id":745706,"data":{"date":"2025-08-11","repo":{"name":"github.com/probably-not/pow","commit":"7b37419c14dae0b4786d59c31edc7242f66fbdd0"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.1,"checks":[{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":0,"reason":"Found 0/12 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go-fieldalignment.yaml:10: update your workflow using https://app.stepsecurity.io/secureworkflow/probably-not/pow/go-fieldalignment.yaml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go-fieldalignment.yaml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/probably-not/pow/go-fieldalignment.yaml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go-mod-tidy.yaml:10: update your workflow using https://app.stepsecurity.io/secureworkflow/probably-not/pow/go-mod-tidy.yaml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go-mod-tidy.yaml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/probably-not/pow/go-mod-tidy.yaml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go-test.yaml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/probably-not/pow/go-test.yaml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go-test.yaml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/probably-not/pow/go-test.yaml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go-vet.yaml:10: update your workflow using https://app.stepsecurity.io/secureworkflow/probably-not/pow/go-vet.yaml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go-vet.yaml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/probably-not/pow/go-vet.yaml/main?enable=pin","Warn: goCommand not pinned by hash: .github/workflows/go-fieldalignment.yaml:17","Info:   0 out of   8 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 goCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/go-fieldalignment.yaml:1","Warn: no topLevel permission defined: .github/workflows/go-mod-tidy.yaml:1","Warn: no topLevel permission defined: .github/workflows/go-test.yaml:1","Warn: no topLevel permission defined: .github/workflows/go-vet.yaml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-22T18:38:57.063Z","repository_id":61627692,"created_at":"2025-08-22T18:38:57.063Z","updated_at":"2025-08-22T18:38:57.063Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34083851,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-08T02:00:07.615Z","response_time":111,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-10T09:16:24.149Z","updated_at":"2026-06-08T23:04:24.120Z","avatar_url":"https://github.com/probably-not.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pow\n\nJust a small experimental scratchpad to test out some performance theories in the classic Closest Power of Two problem.\n\n## The Problem\n\nOne of the classic leetcode problems of this day and age is to calculate the closest power of two to a given input integer. The generally accepted \"correct solution\" is to do some bit shifting magic and calculate the closest power by shifting bits until your binary is a one followed by some zeroes, which tells you that the number is a power of two. While this is a good solution, it's also not an easy one for people who don't read binary or memorize how all bitwise operations work (like myself), so I decided to benchmark doing the bitwise operations vs just simply bruteforcing the solution, by looping until we get the correct number (which is my way of solving the problem).\n\n## Results\n\nThe results were pretty interesting.\n\nI assumed that the bitwise magic would be way faster than the bruteforce solution, but it looks like this only holds true when we have hardcoded our set of bit shifting operations.\n\nSince this would theoretically do extra shift attempts when we don't need them, I wanted to try out adding a for loop so we could cut off the number of shifts, but apparently the overhead of a for loop adds too much of a performance hit.\n\nOn the other hand, from what I can tell, the difference between the Bitwise version with the For loop and the Bruteforce is pretty minimal, (approximately 1ns) which was a pretty surprising revelation! I guess that when bruteforcing with raw math and a for loop vs. bitwise operations and a for loop, the real performance penalty is the for loop itself. From what I could tell, the bitwise operations and math operations have essentially the same overhead (1ns per op), so the for loop adds the major hit.\n\n```\ngoos: darwin\ngoarch: amd64\npkg: github.com/probably-not/pow\ncpu: Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz\nBenchmark_PowerOfTwo_Bitwise-16         346069328                3.521 ns/op           0 B/op          0 allocs/op\nBenchmark_PowerOfTwo_BitwiseFor-16      153441846                7.544 ns/op           0 B/op          0 allocs/op\nBenchmark_PowerOfTwo_BruteForce-16      142918903                8.557 ns/op           0 B/op          0 allocs/op\nPASS\nok      github.com/probably-not/pow     6.008s\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprobably-not%2Fpow","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprobably-not%2Fpow","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprobably-not%2Fpow/lists"}