diff options
| author | qmuntal <quimmuntal@gmail.com> | 2025-02-19 16:05:48 +0100 |
|---|---|---|
| committer | Quim Muntal <quimmuntal@gmail.com> | 2025-02-19 09:41:00 -0800 |
| commit | 6e0a81ac6149e28f75f4e61bd375c4fc426280df (patch) | |
| tree | 34f087395fcabd2624c30c123bc2440dc688784a /src/path | |
| parent | 9ddeac30b5c41f223564e1dedef3095a5a909cb9 (diff) | |
| download | go-6e0a81ac6149e28f75f4e61bd375c4fc426280df.tar.xz | |
path/filepath: use RtlIsDosDeviceName_U to detect Windows devices
RtlIsDosDeviceName_U is specifically designed to detect Windows devices.
We were using GetFullPathName to do this, but it's not the right API
for the job, as it is slower and allocates more memory.
goos: windows
goarch: amd64
pkg: path/filepath
cpu: Intel(R) Core(TM) i7-10850H CPU @ 2.70GHz
│ old.txt │ new.txt │
│ sec/op │ sec/op vs base │
IsLocal-12 5.685µ ± 59% 1.853µ ± 12% -67.41% (p=0.000 n=10)
│ old.txt │ new.txt │
│ B/op │ B/op vs base │
IsLocal-12 496.00 ± 0% 48.00 ± 0% -90.32% (p=0.000 n=10)
│ old.txt │ new.txt │
│ allocs/op │ allocs/op vs base │
IsLocal-12 10.000 ± 0% 6.000 ± 0% -40.00% (p=0.000 n=10)
Change-Id: Ib40ad7a90ab93cf7051c8d6becbce4d287f10f4e
Reviewed-on: https://go-review.googlesource.com/c/go/+/650578
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Diffstat (limited to 'src/path')
| -rw-r--r-- | src/path/filepath/path_test.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/path/filepath/path_test.go b/src/path/filepath/path_test.go index e9cd82d6c5..7ea02a7c28 100644 --- a/src/path/filepath/path_test.go +++ b/src/path/filepath/path_test.go @@ -1889,3 +1889,18 @@ func TestEvalSymlinksTooManyLinks(t *testing.T) { t.Fatal("expected error, got nil") } } + +func BenchmarkIsLocal(b *testing.B) { + tests := islocaltests + if runtime.GOOS == "windows" { + tests = append(tests, winislocaltests...) + } + if runtime.GOOS == "plan9" { + tests = append(tests, plan9islocaltests...) + } + for b.Loop() { + for _, test := range tests { + filepath.IsLocal(test.path) + } + } +} |
