Skip to content

Conversation

1911860538
Copy link

@1911860538 1911860538 commented Sep 4, 2025

In Go 1.25+, strings.SplitSeq offers better performance.
Here are the benchmark results comparing strings.Split
and strings.SplitSeq in a for-loop, with the benchmark
code located in src/strings/iter_test.go:

goos: darwin
goarch: amd64
pkg: strings
cpu: Intel(R) Core(TM) i7-8569U CPU @ 2.80GHz

BenchmarkSplitAndSplitSeq
BenchmarkSplitAndSplitSeq/bySplit_Key_found
BenchmarkSplitAndSplitSeq/bySplit_Key_found-8 14313253 83.19 ns/op 64 B/op 1 allocs/op
BenchmarkSplitAndSplitSeq/bySplitSeq_Key_found
BenchmarkSplitAndSplitSeq/bySplitSeq_Key_found-8 39103686 31.47 ns/op 0 B/op 0 allocs/op
BenchmarkSplitAndSplitSeq/bySplit_Key_not_found
BenchmarkSplitAndSplitSeq/bySplit_Key_not_found-8 11282700 93.85 ns/op 64 B/op 1 allocs/op
BenchmarkSplitAndSplitSeq/bySplitSeq_Key_not_found
BenchmarkSplitAndSplitSeq/bySplitSeq_Key_not_found-8 30754255 39.44 ns/op 0 B/op 0 allocs/op

                                   │   old.txt    │               new.txt               │
                                   │    sec/op    │   sec/op     vs base                │

ParseSpectreNew/empty-8 32.205n ± 1% 9.457n ± 2% -70.64% (p=0.000 n=10)
ParseSpectreNew/index-8 34.76n ± 2% 11.46n ± 4% -67.03% (p=0.000 n=10)
ParseSpectreNew/ret-8 34.65n ± 5% 11.15n ± 2% -67.84% (p=0.000 n=10)
ParseSpectreNew/index_ret-8 50.21n ± 2% 20.98n ± 2% -58.22% (p=0.000 n=10)
ParseSpectreNew/all-8 35.19n ± 3% 11.25n ± 2% -68.02% (p=0.000 n=10)
ParseSpectreNew/multiple_indices_ret-8 195.2n ± 1% 125.1n ± 2% -35.90% (p=0.000 n=10)
geomean 48.72n 18.15n -62.76%

                                   │  old.txt   │                new.txt                 │
                                   │    B/op    │   B/op     vs base                     │

ParseSpectreNew/empty-8 16.00 ± 0% 0.00 ± 0% -100.00% (p=0.000 n=10)
ParseSpectreNew/index-8 16.00 ± 0% 0.00 ± 0% -100.00% (p=0.000 n=10)
ParseSpectreNew/ret-8 16.00 ± 0% 0.00 ± 0% -100.00% (p=0.000 n=10)
ParseSpectreNew/index_ret-8 32.00 ± 0% 0.00 ± 0% -100.00% (p=0.000 n=10)
ParseSpectreNew/all-8 16.00 ± 0% 0.00 ± 0% -100.00% (p=0.000 n=10)
ParseSpectreNew/multiple_indices_ret-8 176.0 ± 0% 0.0 ± 0% -100.00% (p=0.000 n=10)
geomean 26.78 ? ¹ ²
¹ summaries must be >0 to compute geomean
² ratios must be >0 to compute geomean

                                   │  old.txt   │                 new.txt                 │
                                   │ allocs/op  │ allocs/op   vs base                     │

ParseSpectreNew/empty-8 1.000 ± 0% 0.000 ± 0% -100.00% (p=0.000 n=10)
ParseSpectreNew/index-8 1.000 ± 0% 0.000 ± 0% -100.00% (p=0.000 n=10)
ParseSpectreNew/ret-8 1.000 ± 0% 0.000 ± 0% -100.00% (p=0.000 n=10)
ParseSpectreNew/index_ret-8 1.000 ± 0% 0.000 ± 0% -100.00% (p=0.000 n=10)
ParseSpectreNew/all-8 1.000 ± 0% 0.000 ± 0% -100.00% (p=0.000 n=10)
ParseSpectreNew/multiple_indices_ret-8 1.000 ± 0% 0.000 ± 0% -100.00% (p=0.000 n=10)
geomean 1.000 ? ¹ ²
¹ summaries must be >0 to compute geomean
² ratios must be >0 to compute geomean

goos: darwin
goarch: amd64
pkg: cmd/go/internal/auth
cpu: Intel(R) Core(TM) i7-8569U CPU @ 2.80GHz
│ old.txt │ new.txt │
│ sec/op │ sec/op vs base │
ParseGitAuth/standard-8 281.4n ± 1% 218.0n ± 11% -22.54% (p=0.000 n=10)
ParseGitAuth/with_url-8 549.1n ± 1% 480.5n ± 13% -12.48% (p=0.002 n=10)
ParseGitAuth/minimal-8 235.4n ± 1% 197.3n ± 7% -16.20% (p=0.000 n=10)
ParseGitAuth/complex-8 797.6n ± 2% 805.2n ± 4% ~ (p=0.481 n=10)
ParseGitAuth/empty-8 87.48n ± 3% 63.25n ± 6% -27.71% (p=0.000 n=10)
ParseGitAuth/malformed-8 228.8n ± 1% 171.2n ± 3% -25.17% (p=0.000 n=10)
geomean 288.9n 237.7n -17.72%

                     │   old.txt   │              new.txt               │
                     │    B/op     │    B/op     vs base                │

ParseGitAuth/standard-8 192.00 ± 0% 96.00 ± 0% -50.00% (p=0.000 n=10)
ParseGitAuth/with_url-8 400.0 ± 0% 288.0 ± 0% -28.00% (p=0.000 n=10)
ParseGitAuth/minimal-8 144.00 ± 0% 80.00 ± 0% -44.44% (p=0.000 n=10)
ParseGitAuth/complex-8 528.0 ± 0% 400.0 ± 0% -24.24% (p=0.000 n=10)
ParseGitAuth/empty-8 32.00 ± 0% 16.00 ± 0% -50.00% (p=0.000 n=10)
ParseGitAuth/malformed-8 176.00 ± 0% 80.00 ± 0% -54.55% (p=0.000 n=10)
geomean 179.0 102.1 -42.96%

                     │  old.txt   │              new.txt               │
                     │ allocs/op  │ allocs/op   vs base                │

ParseGitAuth/standard-8 3.000 ± 0% 2.000 ± 0% -33.33% (p=0.000 n=10)
ParseGitAuth/with_url-8 4.000 ± 0% 3.000 ± 0% -25.00% (p=0.000 n=10)
ParseGitAuth/minimal-8 3.000 ± 0% 2.000 ± 0% -33.33% (p=0.000 n=10)
ParseGitAuth/complex-8 4.000 ± 0% 3.000 ± 0% -25.00% (p=0.000 n=10)
ParseGitAuth/empty-8 2.000 ± 0% 1.000 ± 0% -50.00% (p=0.000 n=10)
ParseGitAuth/malformed-8 3.000 ± 0% 2.000 ± 0% -33.33% (p=0.000 n=10)
geomean 3.086 2.040 -33.91%

@gopherbot
Copy link
Contributor

This PR (HEAD: c93496b) has been imported to Gerrit for code review.

Please visit Gerrit at https://go-review.googlesource.com/c/go/+/701015.

Important tips:

  • Don't comment on this PR. All discussion takes place in Gerrit.
  • You need a Gmail or other Google account to log in to Gerrit.
  • To change your code in response to feedback:
    • Push a new commit to the branch used by your GitHub PR.
    • A new "patch set" will then appear in Gerrit.
    • Respond to each comment by marking as Done in Gerrit if implemented as suggested. You can alternatively write a reply.
    • Critical: you must click the blue Reply button near the top to publish your Gerrit responses.
    • Multiple commits in the PR will be squashed by GerritBot.
  • The title and description of the GitHub PR are used to construct the final commit message.
    • Edit these as needed via the GitHub web interface (not via Gerrit or git).
    • You should word wrap the PR description at ~76 characters unless you need longer lines (e.g., for tables or URLs).
  • See the Sending a change via GitHub and Reviews sections of the Contribution Guide as well as the FAQ for details.

@gopherbot
Copy link
Contributor

Message from Gopher Robot:

Patch Set 1:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/701015.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from 黄志文:

Patch Set 1:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/701015.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from 黄志文:

Patch Set 1:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/701015.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from qiu laidongfeng:

Patch Set 1: Commit-Queue+1


Please don’t reply on this GitHub thread. Visit golang.org/cl/701015.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Go LUCI:

Patch Set 1:

Dry run: CV is trying the patch.

Bot data: {"action":"start","triggered_at":"2025-09-04T16:53:30Z","revision":"36dbe0cc13b6a7c04877462eb74fd3bb4756b18a"}


Please don’t reply on this GitHub thread. Visit golang.org/cl/701015.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from qiu laidongfeng:

Patch Set 1: -Commit-Queue


Please don’t reply on this GitHub thread. Visit golang.org/cl/701015.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Go LUCI:

Patch Set 1:

This CL has passed the run


Please don’t reply on this GitHub thread. Visit golang.org/cl/701015.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Go LUCI:

Patch Set 1: LUCI-TryBot-Result+1


Please don’t reply on this GitHub thread. Visit golang.org/cl/701015.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Keith Randall:

Patch Set 1:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/701015.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from 黄志文:

Patch Set 1:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/701015.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from 黄志文:

Patch Set 1:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/701015.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Emmanuel Odeke:

Patch Set 1: Commit-Queue+1 Run-TryBot+1


Please don’t reply on this GitHub thread. Visit golang.org/cl/701015.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Go LUCI:

Patch Set 1:

Dry run: CV is trying the patch.

Bot data: {"action":"start","triggered_at":"2025-09-05T07:23:38Z","revision":"36dbe0cc13b6a7c04877462eb74fd3bb4756b18a"}


Please don’t reply on this GitHub thread. Visit golang.org/cl/701015.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gopher Robot:

Patch Set 1:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/701015.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Emmanuel Odeke:

Patch Set 1: -Commit-Queue


Please don’t reply on this GitHub thread. Visit golang.org/cl/701015.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Go LUCI:

Patch Set 1:

This CL has passed the run


Please don’t reply on this GitHub thread. Visit golang.org/cl/701015.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from 黄志文:

Patch Set 1:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/701015.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

This PR (HEAD: f56319c) has been imported to Gerrit for code review.

Please visit Gerrit at https://go-review.googlesource.com/c/go/+/701015.

Important tips:

  • Don't comment on this PR. All discussion takes place in Gerrit.
  • You need a Gmail or other Google account to log in to Gerrit.
  • To change your code in response to feedback:
    • Push a new commit to the branch used by your GitHub PR.
    • A new "patch set" will then appear in Gerrit.
    • Respond to each comment by marking as Done in Gerrit if implemented as suggested. You can alternatively write a reply.
    • Critical: you must click the blue Reply button near the top to publish your Gerrit responses.
    • Multiple commits in the PR will be squashed by GerritBot.
  • The title and description of the GitHub PR are used to construct the final commit message.
    • Edit these as needed via the GitHub web interface (not via Gerrit or git).
    • You should word wrap the PR description at ~76 characters unless you need longer lines (e.g., for tables or URLs).
  • See the Sending a change via GitHub and Reviews sections of the Contribution Guide as well as the FAQ for details.

@gopherbot
Copy link
Contributor

Message from 黄志文:

Patch Set 2:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/701015.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Emmanuel Odeke:

Patch Set 2: Commit-Queue+1 Run-TryBot+1

(2 comments)


Please don’t reply on this GitHub thread. Visit golang.org/cl/701015.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Go LUCI:

Patch Set 2:

Dry run: CV is trying the patch.

Bot data: {"action":"start","triggered_at":"2025-09-05T13:21:28Z","revision":"1a1afff20ad94e562697e6d83b03334345f93a42"}


Please don’t reply on this GitHub thread. Visit golang.org/cl/701015.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gopher Robot:

Patch Set 2:

(2 comments)


Please don’t reply on this GitHub thread. Visit golang.org/cl/701015.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from 黄志文:

Patch Set 2:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/701015.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Emmanuel Odeke:

Patch Set 2: -Commit-Queue


Please don’t reply on this GitHub thread. Visit golang.org/cl/701015.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Go LUCI:

Patch Set 2:

This CL has failed the run. Reason:

Tryjob golang/try/gotip-windows-amd64-longtest has failed with summary (view all results):


To reproduce, try gomote repro 8704563378419271793.

Additional links for debugging:


Please don’t reply on this GitHub thread. Visit golang.org/cl/701015.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Go LUCI:

Patch Set 2: LUCI-TryBot-Result-1


Please don’t reply on this GitHub thread. Visit golang.org/cl/701015.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from 黄志文:

Patch Set 2:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/701015.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from 黄志文:

Patch Set 2:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/701015.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

This PR (HEAD: 9e9bd04) has been imported to Gerrit for code review.

Please visit Gerrit at https://go-review.googlesource.com/c/go/+/701015.

Important tips:

  • Don't comment on this PR. All discussion takes place in Gerrit.
  • You need a Gmail or other Google account to log in to Gerrit.
  • To change your code in response to feedback:
    • Push a new commit to the branch used by your GitHub PR.
    • A new "patch set" will then appear in Gerrit.
    • Respond to each comment by marking as Done in Gerrit if implemented as suggested. You can alternatively write a reply.
    • Critical: you must click the blue Reply button near the top to publish your Gerrit responses.
    • Multiple commits in the PR will be squashed by GerritBot.
  • The title and description of the GitHub PR are used to construct the final commit message.
    • Edit these as needed via the GitHub web interface (not via Gerrit or git).
    • You should word wrap the PR description at ~76 characters unless you need longer lines (e.g., for tables or URLs).
  • See the Sending a change via GitHub and Reviews sections of the Contribution Guide as well as the FAQ for details.

@gopherbot
Copy link
Contributor

Message from 黄志文:

Patch Set 3:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/701015.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

This PR (HEAD: 4db66ee) has been imported to Gerrit for code review.

Please visit Gerrit at https://go-review.googlesource.com/c/go/+/701015.

Important tips:

  • Don't comment on this PR. All discussion takes place in Gerrit.
  • You need a Gmail or other Google account to log in to Gerrit.
  • To change your code in response to feedback:
    • Push a new commit to the branch used by your GitHub PR.
    • A new "patch set" will then appear in Gerrit.
    • Respond to each comment by marking as Done in Gerrit if implemented as suggested. You can alternatively write a reply.
    • Critical: you must click the blue Reply button near the top to publish your Gerrit responses.
    • Multiple commits in the PR will be squashed by GerritBot.
  • The title and description of the GitHub PR are used to construct the final commit message.
    • Edit these as needed via the GitHub web interface (not via Gerrit or git).
    • You should word wrap the PR description at ~76 characters unless you need longer lines (e.g., for tables or URLs).
  • See the Sending a change via GitHub and Reviews sections of the Contribution Guide as well as the FAQ for details.

@gopherbot
Copy link
Contributor

Message from Sean Liao:

Patch Set 4: Commit-Queue+1

(2 comments)


Please don’t reply on this GitHub thread. Visit golang.org/cl/701015.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Go LUCI:

Patch Set 4:

Dry run: CV is trying the patch.

Bot data: {"action":"start","triggered_at":"2025-09-06T09:18:35Z","revision":"1089ed7c6dc8eba046706937e3a771e0ce8ced21"}


Please don’t reply on this GitHub thread. Visit golang.org/cl/701015.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Sean Liao:

Patch Set 4: -Commit-Queue


Please don’t reply on this GitHub thread. Visit golang.org/cl/701015.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Go LUCI:

Patch Set 4:

This CL has passed the run


Please don’t reply on this GitHub thread. Visit golang.org/cl/701015.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Go LUCI:

Patch Set 4: LUCI-TryBot-Result+1


Please don’t reply on this GitHub thread. Visit golang.org/cl/701015.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from 黄志文:

Patch Set 5:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/701015.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Sean Liao:

Patch Set 5:

(3 comments)


Please don’t reply on this GitHub thread. Visit golang.org/cl/701015.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from 黄志文:

Patch Set 5:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/701015.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from 黄志文:

Patch Set 5:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/701015.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from 黄志文:

Patch Set 5:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/701015.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Keith Randall:

Patch Set 5: Code-Review+2

(4 comments)


Please don’t reply on this GitHub thread. Visit golang.org/cl/701015.
After addressing review feedback, remember to publish your drafts!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants