Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various optimizations #3

Merged
merged 3 commits into from
Nov 15, 2023
Merged

Various optimizations #3

merged 3 commits into from
Nov 15, 2023

Conversation

skryukov
Copy link
Owner

Various performance and memory optimizations.

Benchmarks:

value = "google.com"
uni = "fiᆵリ宠퐱卄.com"
puny = "xn--fi-w1k207vk59a3qk9w9r.com"
N = 10_000

report = MemoryProfiler.report do
  N.times {
    URI::IDNA.to_unicode(URI::IDNA.to_ascii(value))
  }
  N.times {
    URI::IDNA.to_unicode(URI::IDNA.to_ascii(uni))
  }
  N.times {
    URI::IDNA.to_unicode(URI::IDNA.to_ascii(puny))
  }
end

report.pretty_print
BEFORE:
Total allocated: 208940164 bytes (3613842 objects)
Total retained:  643926 bytes (8102 objects)

AFTER:
Total allocated: 162245764 bytes (2176480 objects)
Total retained:  749526 bytes (10740 objects)

516 success cases from IdnaTestV2 test suite:

BEFORE:
Calculating -------------------------------------
          to_unicode     84.340  (± 1.2%) i/s -    424.000  in   5.028420s
            to_ascii     66.525  (± 6.0%) i/s -    336.000  in   5.070995s
         to_ascii tr     66.506  (± 4.5%) i/s -    335.000  in   5.055958s

AFTER:
Calculating -------------------------------------
          to_unicode     59.628  (± 0.0%) i/s -    300.000  in   5.031440s
            to_ascii     50.837  (± 0.0%) i/s -    255.000  in   5.016066s
         to_ascii tr     48.980  (± 8.2%) i/s -    245.000  in   5.040046s

@skryukov skryukov merged commit fdc24e5 into main Nov 15, 2023
7 checks passed
@skryukov skryukov deleted the various-optimizations branch November 15, 2023 20:34
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.

None yet

1 participant