commit | 146cd2cecae52ebad6664046fd1430c2a23b55e1 | [log] [tgz] |
---|---|---|
author | adonovan <adonovan@google.com> | Tue Nov 17 11:20:06 2020 -0800 |
committer | Copybara-Service <copybara-worker@google.com> | Tue Nov 17 11:21:15 2020 -0800 |
tree | 57e3f160f28471e669464daf16a7f12f69db80f6 | |
parent | e98442bbf4bc7169b8c05843ab34c94400221593 [diff] |
starlark: a simple benchmark runner This change adds a simple benchmark runner, modelled on Go's testing.B (https://golang.org/pkg/testing/#B). See also discussion in https://github.com/bazelbuild/starlark/pull/75#pullrequestreview-275604129. And https://github.com/bazelbuild/bazel/pull/9195, a JMH-based approach. (Although JMH's measurement logic is of high quality, sadly it cannot be used without annotations, which makes it unsuitable for a completely dynamic suite such as this one.) Each function named bench_* in a file named bench_*.star is executed repeatedly by the runner. The runner provides a parameter, b, that gives, among other things, the number b.n of operations to attempt, and operations to stop, start, or restart the timer. Output: $ bazel run src/test/java/net/starlark/java/eval/Benchmarks File src/test/java/net/starlark/java/eval/testdata/bench_list.star: benchmark ops cpu/op wall/op steps/op bench_append 8191 186µs 183µs 5004 bench_extend 2097151 664ns 618ns 7 File src/test/java/net/starlark/java/eval/testdata/bench_sorted.star: benchmark ops cpu/op wall/op steps/op bench_sort_large 31 40.2619ms 37.3016ms 7 bench_sort_small 4194303 346ns 346ns 7 PiperOrigin-RevId: 342904761
{Fast, Correct} - Choose two
Build and test software of any size, quickly and reliably.
Speed up your builds and tests: Bazel rebuilds only what is necessary. With advanced local and distributed caching, optimized dependency analysis and parallel execution, you get fast and incremental builds.
One tool, multiple languages: Build and test Java, C++, Android, iOS, Go, and a wide variety of other language platforms. Bazel runs on Windows, macOS, and Linux.
Scalable: Bazel helps you scale your organization, codebase, and continuous integration solution. It handles codebases of any size, in multiple repositories or a huge monorepo.
Extensible to your needs: Easily add support for new languages and platforms with Bazel's familiar extension language. Share and re-use language rules written by the growing Bazel community.
Follow our tutorials:
See CONTRIBUTING.md