1
0
mirror of https://github.com/golang/go synced 2024-11-23 21:30:08 -07:00
The Go programming language
Go to file
Tom Thorogood 14e7f174c1 strings: use Builder in ToUpper and ToLower
Map was optimized to use Builder in 45c7d80832, which avoided the []byte
to string converstion. This left the ToUpper and ToLower ASCII fast path
with an extra allocation over Map.

name                                        old time/op    new time/op    delta
ToUpper/#00-12                                3.59ns ± 4%    3.71ns ± 1%     ~     (p=0.056 n=5+5)
ToUpper/ONLYUPPER-12                          11.8ns ± 2%    10.5ns ± 2%  -10.85%  (p=0.008 n=5+5)
ToUpper/abc-12                                31.8ns ± 1%    25.3ns ± 1%  -20.40%  (p=0.008 n=5+5)
ToUpper/AbC123-12                             46.2ns ± 7%    31.9ns ± 8%  -30.89%  (p=0.008 n=5+5)
ToUpper/azAZ09_-12                            47.1ns ± 8%    32.6ns ± 4%  -30.77%  (p=0.008 n=5+5)
ToUpper/longStrinGwitHmixofsmaLLandcAps-12     137ns ±15%     104ns ±11%  -24.11%  (p=0.008 n=5+5)
ToUpper/longɐstringɐwithɐnonasciiⱯchars-12     231ns ± 1%     228ns ± 1%     ~     (p=0.079 n=5+5)
ToUpper/ɐɐɐɐɐ-12                               207ns ± 3%     206ns ± 1%     ~     (p=0.913 n=5+5)
ToUpper/a\u0080\U0010ffff-12                  90.8ns ± 1%    89.6ns ± 1%   -1.30%  (p=0.024 n=5+5)
ToLower/#00-12                                3.59ns ± 1%    4.26ns ± 2%  +18.66%  (p=0.008 n=5+5)
ToLower/abc-12                                6.32ns ± 1%    6.62ns ± 1%   +4.72%  (p=0.008 n=5+5)
ToLower/AbC123-12                             45.0ns ±13%    31.5ns ± 4%  -29.89%  (p=0.008 n=5+5)
ToLower/azAZ09_-12                            48.8ns ± 6%    33.2ns ± 3%  -31.91%  (p=0.008 n=5+5)
ToLower/longStrinGwitHmixofsmaLLandcAps-12     149ns ±13%      98ns ± 8%  -34.30%  (p=0.008 n=5+5)
ToLower/LONGⱯSTRINGⱯWITHⱯNONASCIIⱯCHARS-12     237ns ± 4%     237ns ± 2%     ~     (p=0.635 n=5+5)
ToLower/ⱭⱭⱭⱭⱭ-12                               181ns ± 1%     181ns ± 1%     ~     (p=0.762 n=5+5)
ToLower/A\u0080\U0010ffff-12                  90.6ns ± 1%    92.5ns ± 1%   +2.05%  (p=0.016 n=5+5)

name                                        old alloc/op   new alloc/op   delta
ToUpper/#00-12                                 0.00B          0.00B          ~     (all equal)
ToUpper/ONLYUPPER-12                           0.00B          0.00B          ~     (all equal)
ToUpper/abc-12                                 6.00B ± 0%     3.00B ± 0%  -50.00%  (p=0.008 n=5+5)
ToUpper/AbC123-12                              16.0B ± 0%      8.0B ± 0%  -50.00%  (p=0.008 n=5+5)
ToUpper/azAZ09_-12                             16.0B ± 0%      8.0B ± 0%  -50.00%  (p=0.008 n=5+5)
ToUpper/longStrinGwitHmixofsmaLLandcAps-12     64.0B ± 0%     32.0B ± 0%  -50.00%  (p=0.008 n=5+5)
ToUpper/longɐstringɐwithɐnonasciiⱯchars-12     48.0B ± 0%     48.0B ± 0%     ~     (all equal)
ToUpper/ɐɐɐɐɐ-12                               48.0B ± 0%     48.0B ± 0%     ~     (all equal)
ToUpper/a\u0080\U0010ffff-12                   16.0B ± 0%     16.0B ± 0%     ~     (all equal)
ToLower/#00-12                                 0.00B          0.00B          ~     (all equal)
ToLower/abc-12                                 0.00B          0.00B          ~     (all equal)
ToLower/AbC123-12                              16.0B ± 0%      8.0B ± 0%  -50.00%  (p=0.008 n=5+5)
ToLower/azAZ09_-12                             16.0B ± 0%      8.0B ± 0%  -50.00%  (p=0.008 n=5+5)
ToLower/longStrinGwitHmixofsmaLLandcAps-12     64.0B ± 0%     32.0B ± 0%  -50.00%  (p=0.008 n=5+5)
ToLower/LONGⱯSTRINGⱯWITHⱯNONASCIIⱯCHARS-12     48.0B ± 0%     48.0B ± 0%     ~     (all equal)
ToLower/ⱭⱭⱭⱭⱭ-12                               32.0B ± 0%     32.0B ± 0%     ~     (all equal)
ToLower/A\u0080\U0010ffff-12                   16.0B ± 0%     16.0B ± 0%     ~     (all equal)

name                                        old allocs/op  new allocs/op  delta
ToUpper/#00-12                                  0.00           0.00          ~     (all equal)
ToUpper/ONLYUPPER-12                            0.00           0.00          ~     (all equal)
ToUpper/abc-12                                  2.00 ± 0%      1.00 ± 0%  -50.00%  (p=0.008 n=5+5)
ToUpper/AbC123-12                               2.00 ± 0%      1.00 ± 0%  -50.00%  (p=0.008 n=5+5)
ToUpper/azAZ09_-12                              2.00 ± 0%      1.00 ± 0%  -50.00%  (p=0.008 n=5+5)
ToUpper/longStrinGwitHmixofsmaLLandcAps-12      2.00 ± 0%      1.00 ± 0%  -50.00%  (p=0.008 n=5+5)
ToUpper/longɐstringɐwithɐnonasciiⱯchars-12      1.00 ± 0%      1.00 ± 0%     ~     (all equal)
ToUpper/ɐɐɐɐɐ-12                                2.00 ± 0%      2.00 ± 0%     ~     (all equal)
ToUpper/a\u0080\U0010ffff-12                    1.00 ± 0%      1.00 ± 0%     ~     (all equal)
ToLower/#00-12                                  0.00           0.00          ~     (all equal)
ToLower/abc-12                                  0.00           0.00          ~     (all equal)
ToLower/AbC123-12                               2.00 ± 0%      1.00 ± 0%  -50.00%  (p=0.008 n=5+5)
ToLower/azAZ09_-12                              2.00 ± 0%      1.00 ± 0%  -50.00%  (p=0.008 n=5+5)
ToLower/longStrinGwitHmixofsmaLLandcAps-12      2.00 ± 0%      1.00 ± 0%  -50.00%  (p=0.008 n=5+5)
ToLower/LONGⱯSTRINGⱯWITHⱯNONASCIIⱯCHARS-12      1.00 ± 0%      1.00 ± 0%     ~     (all equal)
ToLower/ⱭⱭⱭⱭⱭ-12                                1.00 ± 0%      1.00 ± 0%     ~     (all equal)
ToLower/A\u0080\U0010ffff-12                    1.00 ± 0%      1.00 ± 0%     ~     (all equal)

Updates #26304

Change-Id: I4179e21d5e60d950b925fe3ffc74b376b82812d2
GitHub-Last-Rev: 2c7c3bb75b
GitHub-Pull-Request: golang/go#27872
Reviewed-on: https://go-review.googlesource.com/137575
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-09-26 14:41:52 +00:00
.github .github: use HTTPS for Stack Overflow link in SUPPORT.md 2018-06-12 11:08:14 +00:00
api os: add ModeCharDevice to ModeType 2018-09-13 09:52:57 +00:00
doc doc/faq: fix link to 2018 ISMM keynote 2018-09-25 18:02:45 +00:00
lib/time lib/time: update vendored tzdata to release 2018e 2018-06-11 14:47:06 +00:00
misc compress: reduce copies of new text for compression testing 2018-09-24 18:26:02 +00:00
src strings: use Builder in ToUpper and ToLower 2018-09-26 14:41:52 +00:00
test test: restore binary.BigEndian use in checkbce 2018-09-24 21:20:51 +00:00
.gitattributes
.gitignore .gitignore: ignore src/cmd/dist/dist 2017-10-28 21:55:49 +00:00
AUTHORS A+C: add VMware as author, Venil Noronha as contributor 2018-08-31 02:14:24 +00:00
CONTRIBUTING.md all: restore changes from faulty merge/revert 2018-02-12 20:13:59 +00:00
CONTRIBUTORS A+C: add VMware as author, Venil Noronha as contributor 2018-08-31 02:14:24 +00:00
favicon.ico website: recreate 16px and 32px favicon 2016-08-25 15:43:32 +00:00
LICENSE
PATENTS
README.md README: linkify some paths 2018-06-06 18:07:01 +00:00
robots.txt

The Go Programming Language

Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.

Gopher image Gopher image by Renee French, licensed under Creative Commons 3.0 Attributions license.

Our canonical Git repository is located at https://go.googlesource.com/go. There is a mirror of the repository at https://github.com/golang/go.

Unless otherwise noted, the Go source files are distributed under the BSD-style license found in the LICENSE file.

Download and Install

Binary Distributions

Official binary distributions are available at https://golang.org/dl/.

After downloading a binary release, visit https://golang.org/doc/install or load doc/install.html in your web browser for installation instructions.

Install From Source

If a binary distribution is not available for your combination of operating system and architecture, visit https://golang.org/doc/install/source or load doc/install-source.html in your web browser for source installation instructions.

Contributing

Go is the work of thousands of contributors. We appreciate your help!

To contribute, please read the contribution guidelines: https://golang.org/doc/contribute.html

Note that the Go project uses the issue tracker for bug reports and proposals only. See https://golang.org/wiki/Questions for a list of places to ask questions about the Go language.