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

Avoid modifying unnecessary nodes for performance #15

Merged
merged 1 commit into from
Mar 16, 2024

Conversation

pocke
Copy link
Owner

@pocke pocke commented Mar 16, 2024

Benchmarking

# Benchmarking #to_sql mehtod

## Wihtout AR::Originator
ruby benchmark/to_sql.rb
-- create_table(:posts, {:force=>true})
   -> 0.0306s
ruby 3.4.0dev (2024-02-06T03:19:56Z master 4f6b827e98) [arm64-darwin21]
Warming up --------------------------------------
       without where     5.608k i/100ms
with single condition
                         1.890k i/100ms
with multiple condition
                       740.000 i/100ms
Calculating -------------------------------------
       without where     55.488k (± 0.7%) i/s -    280.400k in   5.053643s
with single condition
                         18.992k (± 2.6%) i/s -     96.390k in   5.078771s
with multiple condition
                          7.378k (± 2.3%) i/s -     37.000k in   5.017968s

## With AR::Originator
ruby -r activerecord/originator benchmark/to_sql.rb
-- create_table(:posts, {:force=>true})
   -> 0.0229s
ruby 3.4.0dev (2024-02-06T03:19:56Z master 4f6b827e98) [arm64-darwin21]
Warming up --------------------------------------
       without where     5.295k i/100ms
with single condition
                         1.469k i/100ms
with multiple condition
                       523.000 i/100ms
Calculating -------------------------------------
       without where     54.545k (± 0.8%) i/s -    275.340k in   5.048271s
with single condition
                         14.777k (± 1.0%) i/s -     74.919k in   5.070334s
with multiple condition
                          5.180k (± 1.4%) i/s -     26.150k in   5.049379s
# Benchmarking SELECT Query

## Wihtout AR::Originator
ruby benchmark/select_query.rb
-- create_table(:posts, {:force=>true})
   -> 0.0277s
ruby 3.4.0dev (2024-02-06T03:19:56Z master 4f6b827e98) [arm64-darwin21]
Warming up --------------------------------------
       without where   263.000 i/100ms
with single condition
                       915.000 i/100ms
with multiple condition
                       393.000 i/100ms
Calculating -------------------------------------
       without where      2.611k (± 1.5%) i/s -     13.150k in   5.036591s
with single condition
                          9.087k (± 1.6%) i/s -     45.750k in   5.035960s
with multiple condition
                          3.898k (± 2.3%) i/s -     19.650k in   5.043484s

## With AR::Originator
ruby -r activerecord/originator benchmark/select_query.rb
-- create_table(:posts, {:force=>true})
   -> 0.0322s
ruby 3.4.0dev (2024-02-06T03:19:56Z master 4f6b827e98) [arm64-darwin21]
Warming up --------------------------------------
       without where   265.000 i/100ms
with single condition
                       787.000 i/100ms
with multiple condition
                       323.000 i/100ms
Calculating -------------------------------------
       without where      2.636k (± 1.1%) i/s -     13.250k in   5.026309s
with single condition
                          7.793k (± 2.6%) i/s -     39.350k in   5.052717s
with multiple condition
                          3.234k (± 1.9%) i/s -     16.473k in   5.095316s

@pocke pocke merged commit 7c32d29 into master Mar 16, 2024
4 checks passed
@pocke pocke deleted the Avoid_modifying_unnecessary_nodes branch March 16, 2024 09:40
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