go/src
Russ Cox f8f08bfd7c math/big: improve scan test and benchmark
Add a few more test cases for scanning (integer conversion),
which were helpful in debugging some upcoming changes.

BenchmarkScan currently times converting the value 10**N
represented in base B back into []Word form.
When B = 10, the text is 1 followed by many zeros, which
could hit a "multiply by zero" special case when processing
many digit chunks, misrepresenting the actual time required
depending on whether that case is optimized.

Change the benchmark to use 9**N, which is about as big and
will not cause runs of zeros in any of the tested bases.

The benchmark comparison below is not showing faster code,
since of course the code is not changing at all here. Instead,
it is showing that the new benchmark work is roughly the same
size as the old benchmark work.

goos: darwin
goarch: arm64
pkg: math/big
cpu: Apple M3 Pro
                      │     old     │                new                 │
                      │   sec/op    │   sec/op     vs base               │
ScanPi-12               43.35µ ± 1%   43.59µ ± 1%       ~ (p=0.069 n=15)
Scan/10/Base2-12        202.3n ± 2%   193.7n ± 1%  -4.25% (p=0.000 n=15)
Scan/100/Base2-12       1.512µ ± 3%   1.447µ ± 1%  -4.30% (p=0.000 n=15)
Scan/1000/Base2-12      15.06µ ± 2%   14.33µ ± 0%  -4.83% (p=0.000 n=15)
Scan/10000/Base2-12     188.0µ ± 5%   177.3µ ± 1%  -5.65% (p=0.000 n=15)
Scan/100000/Base2-12    5.814m ± 3%   5.382m ± 1%  -7.43% (p=0.000 n=15)
Scan/10/Base8-12        78.57n ± 2%   75.02n ± 1%  -4.52% (p=0.000 n=15)
Scan/100/Base8-12       548.2n ± 2%   526.8n ± 1%  -3.90% (p=0.000 n=15)
Scan/1000/Base8-12      5.674µ ± 2%   5.421µ ± 0%  -4.46% (p=0.000 n=15)
Scan/10000/Base8-12     94.42µ ± 1%   88.61µ ± 1%  -6.15% (p=0.000 n=15)
Scan/100000/Base8-12    4.906m ± 2%   4.498m ± 3%  -8.31% (p=0.000 n=15)
Scan/10/Base10-12       73.42n ± 1%   69.56n ± 0%  -5.26% (p=0.000 n=15)
Scan/100/Base10-12      511.9n ± 1%   488.2n ± 0%  -4.63% (p=0.000 n=15)
Scan/1000/Base10-12     5.254µ ± 2%   5.009µ ± 0%  -4.66% (p=0.000 n=15)
Scan/10000/Base10-12    90.22µ ± 2%   84.52µ ± 0%  -6.32% (p=0.000 n=15)
Scan/100000/Base10-12   4.842m ± 3%   4.471m ± 3%  -7.65% (p=0.000 n=15)
Scan/10/Base16-12       62.28n ± 1%   58.70n ± 1%  -5.75% (p=0.000 n=15)
Scan/100/Base16-12      398.6n ± 0%   377.9n ± 1%  -5.19% (p=0.000 n=15)
Scan/1000/Base16-12     4.108µ ± 1%   3.782µ ± 0%  -7.94% (p=0.000 n=15)
Scan/10000/Base16-12    83.78µ ± 2%   80.51µ ± 1%  -3.90% (p=0.000 n=15)
Scan/100000/Base16-12   5.080m ± 3%   4.698m ± 3%  -7.53% (p=0.000 n=15)
geomean                 12.41µ        11.74µ       -5.36%

Change-Id: If3ce290ecc7f38672f11b42fd811afb53dee665d
Reviewed-on: https://go-review.googlesource.com/c/go/+/650639
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Russ Cox <rsc@golang.org>
2025-02-27 05:58:49 -08:00
..
archive
arena
bufio
builtin
bytes bytes,strings: remove redundant return statement for Lines 2025-02-19 10:22:08 -08:00
cmd cmd/internal/obj/riscv: implement vector load/store instructions 2025-02-27 03:47:20 -08:00
cmp
compress all: use a more straightforward return value 2025-02-18 09:28:50 -08:00
container
context context: replace newAfterFuncContext with a global declaration using blank identifier 2025-02-20 08:16:29 -08:00
crypto crypto/internal/fips140/edwards25519/field: optimize AMD64 2025-02-26 13:58:20 -08:00
database/sql
debug debug/buildinfo: base64-encode test binaries 2025-02-20 14:20:00 -08:00
embed
encoding encoding/json: use builtin min function in appendString 2025-02-25 11:49:13 -08:00
errors
expvar
flag all: use testenv.Executable instead of os.Executable and os.Args[0] 2025-02-24 11:03:10 -08:00
fmt
go go/scanner: report specific error for UCS-2 encoded files 2025-02-25 19:23:05 -08:00
hash
html html/template: add available godoc link 2025-02-19 13:39:04 -08:00
image
index/suffixarray
internal all: use testenv.GoToolPath instead of hardcoding go 2025-02-25 12:01:35 -08:00
io std: add //go:fix inline directives to some deprecated functions 2025-02-15 08:06:58 -08:00
iter
log all: use a more straightforward return value 2025-02-18 09:28:50 -08:00
maps
math math/big: improve scan test and benchmark 2025-02-27 05:58:49 -08:00
mime
net net: return proper error from Context 2025-02-26 14:16:12 -08:00
os os, syscall: use unix build tag where appropriate 2025-02-25 12:09:25 -08:00
path path/filepath: use RtlIsDosDeviceName_U to detect Windows devices 2025-02-19 09:41:00 -08:00
plugin
reflect reflect: let Value.Seq return the iteration value correct type 2025-02-26 09:41:14 -08:00
regexp
runtime runtime/cgo: use standard ABI call setg_gcc in crosscall1 on loong64 2025-02-26 17:36:57 -08:00
slices
sort
strconv strconv: use builtin min function in commonPrefixLenIgnoreCase 2025-02-24 17:38:00 -08:00
strings bytes,strings: remove redundant return statement for Lines 2025-02-19 10:22:08 -08:00
structs
sync sync: don't keep func alive after OnceFunc panics 2025-02-26 12:52:02 -08:00
syscall os, syscall: use unix build tag where appropriate 2025-02-25 12:09:25 -08:00
testdata
testing all: use testenv.Executable instead of os.Executable and os.Args[0] 2025-02-24 11:03:10 -08:00
text all: gofmt -w 2025-02-25 11:49:16 -08:00
time
unicode unicode/utf8: use builtin max function to simplify code 2025-02-25 10:16:36 -08:00
unique unique: use runtime.AddCleanup instead of runtime.SetFinalizer 2025-02-24 09:11:32 -08:00
unsafe
vendor net/http, net/http/internal/httpcommon: add httpcommon package 2025-02-13 16:29:58 -08:00
weak weak: test the use of runtime.AddCleanup 2025-02-25 08:44:32 -08:00
Make.dist
README.vendor
all.bash
all.bat
all.rc
bootstrap.bash
buildall.bash
clean.bash
clean.bat
clean.rc
cmp.bash
go.mod net/http, net/http/internal/httpcommon: add httpcommon package 2025-02-13 16:29:58 -08:00
go.sum net/http, net/http/internal/httpcommon: add httpcommon package 2025-02-13 16:29:58 -08:00
make.bash
make.bat
make.rc
race.bash
race.bat
run.bash
run.bat
run.rc

README.vendor

Vendoring in std and cmd
========================

The Go command maintains copies of external packages needed by the
standard library in the src/vendor and src/cmd/vendor directories.

There are two modules, std and cmd, defined in src/go.mod and
src/cmd/go.mod. When a package outside std or cmd is imported
by a package inside std or cmd, the import path is interpreted
as if it had a "vendor/" prefix. For example, within "crypto/tls",
an import of "golang.org/x/crypto/cryptobyte" resolves to
"vendor/golang.org/x/crypto/cryptobyte". When a package with the
same path is imported from a package outside std or cmd, it will
be resolved normally. Consequently, a binary may be built with two
copies of a package at different versions if the package is
imported normally and vendored by the standard library.

Vendored packages are internally renamed with a "vendor/" prefix
to preserve the invariant that all packages have distinct paths.
This is necessary to avoid compiler and linker conflicts. Adding
a "vendor/" prefix also maintains the invariant that standard
library packages begin with a dotless path element.

The module requirements of std and cmd do not influence version
selection in other modules. They are only considered when running
module commands like 'go get' and 'go mod vendor' from a directory
in GOROOT/src.

Maintaining vendor directories
==============================

Before updating vendor directories, ensure that module mode is enabled.
Make sure that GO111MODULE is not set in the environment, or that it is
set to 'on' or 'auto', and if you use a go.work file, set GOWORK=off.

Also, ensure that 'go env GOROOT' shows the root of this Go source
tree. Otherwise, the results are undefined. It's recommended to build
Go from source and use that 'go' binary to update its source tree.

Requirements may be added, updated, and removed with 'go get'.
The vendor directory may be updated with 'go mod vendor'.
A typical sequence might be:

    cd src  # or src/cmd
    go get golang.org/x/net@master
    go mod tidy
    go mod vendor

Use caution when passing '-u' to 'go get'. The '-u' flag updates
modules providing all transitively imported packages, not only
the module providing the target package.

Note that 'go mod vendor' only copies packages that are transitively
imported by packages in the current module. If a new package is needed,
it should be imported before running 'go mod vendor'.