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

Optimize performance of keys definition #47

Closed
wants to merge 1 commit into from
Closed

Conversation

Goltergaul
Copy link
Owner

@Goltergaul Goltergaul commented Nov 22, 2023

This is only improving performance. Benchmark results are from this script: https://github.com/Goltergaul/definition/blob/performance/benchmark/model.rb (master vs this branch)

Before definition was slower by 1.21x, after it is faster by 1.13x in the valid data scenario

performance before:

Benchmark with valid input data:
Warming up --------------------------------------
          definition    12.167k i/100ms
          dry-struct    15.855k i/100ms
Calculating -------------------------------------
          definition    112.708k (± 5.6%) i/s -      2.251M in  20.036174s
          dry-struct    136.525k (± 2.1%) i/s -      2.743M in  20.100323s

Comparison:
          dry-struct:   136525.3 i/s
          definition:   112708.0 i/s - 1.21x  slower

Benchmark with invalid input data:
Warming up --------------------------------------
          definition     4.951k i/100ms
          dry-struct     3.166k i/100ms
Calculating -------------------------------------
          definition     50.435k (± 4.2%) i/s -      1.010M in  20.071097s
          dry-struct     32.269k (± 2.9%) i/s -    645.864k in  20.032104s

Comparison:
          definition:    50434.5 i/s
          dry-struct:    32269.2 i/s - 1.56x  slower

Performance after:

Benchmark with valid input data:
Warming up --------------------------------------
          definition    14.813k i/100ms
          dry-struct    15.516k i/100ms
Calculating -------------------------------------
          definition    150.088k (± 4.7%) i/s -      3.007M in  20.083543s
          dry-struct    132.421k (± 1.4%) i/s -      2.653M in  20.040159s

Comparison:
          definition:   150088.4 i/s
          dry-struct:   132421.5 i/s - 1.13x  slower

Benchmark with invalid input data:
Warming up --------------------------------------
          definition     6.173k i/100ms
          dry-struct     3.865k i/100ms
Calculating -------------------------------------
          definition     56.998k (± 9.4%) i/s -      1.130M in  20.046251s
          dry-struct     35.420k (±12.0%) i/s -    695.700k in  20.057381s

Comparison:
          definition:    56998.3 i/s
          dry-struct:    35420.2 i/s - 1.61x  slower

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.

1 participant