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

Rewrite and operator with #index #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

yichaulin
Copy link

Description

#index uses less allocations and has better performance than #find

Performance Benchmark

Test Suit

require 'benchmark/ips'
require "bundler/gem_tasks"
require 'json_logic'

logic = {
  "and" => [true, 1, 'a']
}


compiled = JSONLogic.compile(logic)

Benchmark.ips do |x|
  x.report("and_operator") { compiled.evaluate(nil) }

  x.compare!
end

Before PR

Warming up --------------------------------------
        and_operator   131.476k i/100ms
Calculating -------------------------------------
        and_operator      1.319M (± 0.5%) i/s -      6.705M in   5.085356s

After PR

Warming up --------------------------------------
        and_operator   145.108k i/100ms
Calculating -------------------------------------
        and_operator      1.471M (± 0.7%) i/s -      7.401M in   5.031494s

About 11% improvement

@fill32
Copy link

fill32 commented May 14, 2023

#index uses less allocations and has better performance than #find

should put the source of this insight into this PR.

About 11% improvement.

this result was from your local computer? can check this on staging also if you have time.

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.

2 participants