-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid char array allocation in Starlark
format
Positional access via `String#charAt` is slightly faster than precreating the char array for Latin-1 strings and much faster for UTF-8 strings. It allocates less in both cases. Also adds a `--latin1` flag to the `Benchmarks` tool that allows benchmarking against Bazel's way of parsing Starlark files. Before: ``` INFO: Running command line: bazel-bin/src/test/java/net/starlark/java/eval/Benchmarks --filter bench_format --seconds 20 File src/test/java/net/starlark/java/eval/testdata/bench_string.star: benchmark ops cpu/op wall/op steps/op alloc/op bench_format 134217727 169ns 168ns 7 495B INFO: Running command line: bazel-bin/src/test/java/net/starlark/java/eval/Benchmarks --filter bench_format --seconds 20 --latin1 File src/test/java/net/starlark/java/eval/testdata/bench_string.star: benchmark ops cpu/op wall/op steps/op alloc/op bench_format 268435455 122ns 121ns 7 495B ``` After: ``` INFO: Running command line: bazel-bin/src/test/java/net/starlark/java/eval/Benchmarks --filter bench_format --seconds 20 File src/test/java/net/starlark/java/eval/testdata/bench_string.star: benchmark ops cpu/op wall/op steps/op alloc/op bench_format 268435455 110ns 109ns 7 479B INFO: Running command line: bazel-bin/src/test/java/net/starlark/java/eval/Benchmarks --filter bench_format --seconds 20 --latin1 File src/test/java/net/starlark/java/eval/testdata/bench_string.star: benchmark ops cpu/op wall/op steps/op alloc/op bench_format 268435455 113ns 112ns 7 479B ```
- Loading branch information
Showing
3 changed files
with
53 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters