{"id":13995361,"url":"https://github.com/google/swift-benchmark","last_synced_at":"2025-10-21T10:56:01.003Z","repository":{"id":44544726,"uuid":"262342606","full_name":"google/swift-benchmark","owner":"google","description":"A swift library to benchmark code snippets.","archived":false,"fork":false,"pushed_at":"2022-05-10T10:15:36.000Z","size":170,"stargazers_count":931,"open_issues_count":18,"forks_count":50,"subscribers_count":21,"default_branch":"main","last_synced_at":"2025-06-19T16:19:17.954Z","etag":null,"topics":["benchmark-framework","benchmarking","swift","swiftpackage","swiftpm"],"latest_commit_sha":null,"homepage":"","language":"Swift","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/google.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-05-08T14:18:30.000Z","updated_at":"2025-06-14T14:13:11.000Z","dependencies_parsed_at":"2022-08-22T15:32:13.699Z","dependency_job_id":null,"html_url":"https://github.com/google/swift-benchmark","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/google/swift-benchmark","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google%2Fswift-benchmark","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google%2Fswift-benchmark/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google%2Fswift-benchmark/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google%2Fswift-benchmark/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/google","download_url":"https://codeload.github.com/google/swift-benchmark/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google%2Fswift-benchmark/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266488397,"owners_count":23937352,"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","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"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":["benchmark-framework","benchmarking","swift","swiftpackage","swiftpm"],"created_at":"2024-08-09T14:03:22.018Z","updated_at":"2025-10-21T10:55:55.971Z","avatar_url":"https://github.com/google.png","language":"Swift","readme":"# swift-benchmark\n\nA Swift library for benchmarking code snippets, similar to\n[google/benchmark](https://github.com/google/benchmark).\n\nExample:\n\n```swift\nimport Benchmark\n\nbenchmark(\"add string reserved capacity\") {\n    var x: String = \"\"\n    x.reserveCapacity(2000)\n    for _ in 1...1000 {\n        x += \"hi\"\n    }\n}\n\nBenchmark.main()\n```\n\nAt runtime, you can filter which benchmarks to run by using the `--filter` command line flag. For\nmore details on what options are available, pass either the `-h` or `--help` command line flags.\n\nExample:\n\n```terminal\n$ swift run -c release BenchmarkMinimalExample --help\nUSAGE: benchmark-command [--allow-debug-build] [--filter \u003cfilter\u003e] [--filter-not \u003cfilter-not\u003e] [--iterations \u003citerations\u003e] [--warmup-iterations \u003cwarmup-iterations\u003e] [--min-time \u003cmin-time\u003e] [--max-iterations \u003cmax-iterations\u003e] [--time-unit \u003ctime-unit\u003e] [--inverse-time-unit \u003cinverse-time-unit\u003e] [--columns \u003ccolumns\u003e] [--format \u003cformat\u003e] [--quiet]\n\nOPTIONS:\n  --allow-debug-build     Overrides check to verify optimized build.\n  --filter \u003cfilter\u003e       Run only benchmarks whose names match the regular expression.\n  --filter-not \u003cfilter-not\u003e\n                          Exclude benchmarks whose names match the regular expression.\n  --iterations \u003citerations\u003e\n                          Number of iterations to run.\n  --warmup-iterations \u003cwarmup-iterations\u003e\n                          Number of warm-up iterations to run.\n  --min-time \u003cmin-time\u003e   Minimal time to run when automatically detecting number iterations.\n  --max-iterations \u003cmax-iterations\u003e\n                          Maximum number of iterations to run when automatically detecting number iterations.\n  --time-unit \u003ctime-unit\u003e Time unit used to report the timing results.\n  --inverse-time-unit \u003cinverse-time-unit\u003e\n                          Inverse time unit used to report throughput results.\n  --columns \u003ccolumns\u003e     Comma-separated list of column names to show.\n  --format \u003cformat\u003e       Output format (valid values are: json, csv, console, none).\n  --quiet                 Only print final benchmark results.\n  -h, --help              Show help information.\n\n$ swift run -c release BenchmarkMinimalExample\nrunning add string no capacity... done! (1832.52 ms)\nrunning add string reserved capacity... done! (1813.96 ms)\n\nname                         time     std        iterations\n-----------------------------------------------------------\nadd string no capacity       37435 ns ±   6.22 %      37196\nadd string reserved capacity 37022 ns ±   1.75 %      37749\n```\n\nFor more examples, see\n[Sources/BenchmarkMinimalExample](./Sources/BenchmarkMinimalExample) and\n[Sources/BenchmarkSuiteExample](./Sources/BenchmarkSuiteExample).\n\n## Usage\n\nAdd this library as a SwiftPM dependency:\n\n```swift\nlet package = Package(\n    name: ... ,\n    products: [\n        .executable(name: \"Benchmarks\", targets: [\"Benchmarks\"])\n    ],\n    dependencies: [\n      .package(url: \"https://github.com/google/swift-benchmark\", from: \"0.1.0\")\n    ],\n    targets: [\n        .target(\n            name: \"Benchmarks\",\n            dependencies: [.product(name: \"Benchmark\", package: \"swift-benchmark\")]\n        )\n    ]\n)\n```\n\n## Roadmap\n\nThe project is in an early stage and offers only a basic set of benchmarking\nutilities. Feel free to file issues and feature requests to help us prioritize\nwhat to do next.\n\n## License\n\nPlease see [LICENSE](LICENSE) for details.\n\n## Contributing\n\nPlease see [CONTRIBUTING.md] for details.\n\n[CONTRIBUTING.md]: CONTRIBUTING.md\n\n","funding_links":[],"categories":["Swift"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoogle%2Fswift-benchmark","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgoogle%2Fswift-benchmark","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoogle%2Fswift-benchmark/lists"}