Skip to content

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