{"id":20321357,"url":"https://github.com/openacid/gobenchmark","last_synced_at":"2025-04-11T19:10:25.330Z","repository":{"id":64302217,"uuid":"190370642","full_name":"openacid/gobenchmark","owner":"openacid","description":"A collection of benchmarks of basic operation, as a guide for tuning.","archived":false,"fork":false,"pushed_at":"2021-04-12T03:30:43.000Z","size":26,"stargazers_count":12,"open_issues_count":12,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-25T15:03:46.175Z","etag":null,"topics":["benchmark","go","golang"],"latest_commit_sha":null,"homepage":null,"language":"Go","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/openacid.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-06-05T09:56:48.000Z","updated_at":"2024-11-28T02:44:50.000Z","dependencies_parsed_at":"2023-01-15T09:45:47.904Z","dependency_job_id":null,"html_url":"https://github.com/openacid/gobenchmark","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openacid%2Fgobenchmark","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openacid%2Fgobenchmark/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openacid%2Fgobenchmark/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openacid%2Fgobenchmark/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/openacid","download_url":"https://codeload.github.com/openacid/gobenchmark/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248465344,"owners_count":21108244,"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","go","golang"],"created_at":"2024-11-14T19:14:27.076Z","updated_at":"2025-04-11T19:10:25.311Z","avatar_url":"https://github.com/openacid.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!-- START doctoc generated TOC please keep comment here to allow auto update --\u003e\n\u003c!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --\u003e\n**Table of Contents**  *generated with [DocToc](https://github.com/thlorenz/doctoc)*\n\n- [gobenchmark](#gobenchmark)\n- [What it is NOT](#what-it-is-not)\n- [Use it](#use-it)\n- [Install](#install)\n- [Tips for tuning](#tips-for-tuning)\n- [Pre-built benchmarks](#pre-built-benchmarks)\n\n\u003c!-- END doctoc generated TOC please keep comment here to allow auto update --\u003e\n\n# gobenchmark\nA collection of benchmarks of basic operation, as a guide for tuning.\n\nWhen digging deeper and deeper into performance tuning, we found the performance\nof some basic operations varies widely, in a counter-intuitive way.\nThese differences are critical and does impact performance.\nThus we have benchmarked basic operations, to establish a solid guide for people\nworking on performance critical programs.\n\n\n# What it is NOT\n\n- Cache missing or memory layout caused performance issues are not included yet.\n\n\n# Use it\n\nThe statistics listed below gives us a intuitive view of basic operation performances.\n**But it is strongly recommended to re-benchmark it on your platform before using it**,\nsince performance may vary on different architectures.\n\n\n# Install\n\n```sh\ngo get github.com/openacid/gobenchmark\n\nmake ben # run the benchmark\n```\n\n# Tips for tuning\n\nAccording to the benchmark, there are some general tips for tuning computation\ndense programs:\n\n-   Usually using static data is faster:\n    -   **Most of the time**, operating on a const is faster than on a variable.\n    -   Using array is (about 2 times) faster than using a slice.\n\n-   Integer are faster than float number.\n\n-   Usually `/` and `%` are very slow. Use shift if possible.\n\n\n\n# Pre-built benchmarks\n\n```txt\ngoos: darwin \ngoarch: amd64 \npkg: github.com/openacid/gobenchmark \nBenchmarkInt64_And_ByConst_Assign-8                   0.364 ns/op -\nBenchmarkInt64_And_ByVar_Assign-8                     0.397 ns/op -\nBenchmarkInt64_Or_ByConst_Assign-8                    0.363 ns/op -\nBenchmarkInt64_Or_ByVar_Assign-8                      0.400 ns/op --\nBenchmarkInt64_Xor_ByConst_Assign-8                   0.367 ns/op -\nBenchmarkInt64_Xor_ByVar_Assign-8                     0.409 ns/op --\nBenchmarkInt64_Add_ByConst_Assign-8                   0.528 ns/op --\nBenchmarkInt64_Add_ByVar_Assign-8                     0.394 ns/op -\nBenchmarkInt64_Sub_ByConst_Assign-8                   0.526 ns/op --\nBenchmarkInt64_Sub_ByVar_Assign-8                     0.400 ns/op --\nBenchmarkInt64_Multi_ByConst_Assign-8                 0.404 ns/op --\nBenchmarkInt64_Multi_ByVar_Assign-8                   0.428 ns/op --\nBenchmarkInt64_ShiftLeft_ByConst_Assign-8             0.359 ns/op -\nBenchmarkInt64_ShiftLeft_ByVar_Assign-8               0.952 ns/op ----\nBenchmarkInt64_ShiftRight_ByConst_Assign-8            0.362 ns/op -\nBenchmarkInt64_ShiftRight_ByVar_Assign-8              1.45 ns/op -------\nBenchmarkInt64_Div_ByConst_Assign-8                   1.01 ns/op -----\nBenchmarkInt64_Div_ByVar_Assign-8                     8.18 ns/op ----------------------------------------\nBenchmarkInt64_Mod_ByConst_Assign-8                   1.05 ns/op -----\nBenchmarkInt64_Mod_ByVar_Assign-8                     8.46 ns/op ------------------------------------------\nBenchmarkInt64_Assign-8                               0.268 ns/op -\nBenchmarkFloat64_Multi_ByConst_Assign-8               0.811 ns/op ----\nBenchmarkFloat64_Multi_ByVar_Assign-8                 0.813 ns/op ----\nBenchmarkFloat64_Div_ByConst_Assign-8                 3.73 ns/op ------------------\nBenchmarkFloat64_Div_ByVar_Assign-8                   3.68 ns/op ------------------\nBenchmarkFloat64_ToInt64_Assign-8                     0.554 ns/op --\nBenchmarkFloat64_Assign-8                             0.777 ns/op ---\nBenchmarkInt64Array_Get_Assign-8                      0.265 ns/op -\nBenchmarkInt64Slice_Get_Assign-8                      0.535 ns/op --\nPASS \nok  \tgithub.com/openacid/gobenchmark.221s \n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenacid%2Fgobenchmark","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopenacid%2Fgobenchmark","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenacid%2Fgobenchmark/lists"}