• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

lotus / utils / 236 / 6
98%
master: 98%

Build:
DEFAULT BRANCH: master
Ran 22 Jan 2015 11:29PM UTC
Files 12
Run time 6s
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

22 Jan 2015 11:13PM UTC coverage: 96.124%. First build
2.1.4

Pull #52

travis-ci

weppos
Extract out common logic to prepare the callables

I benchmarked the results, and the change is justifiable. There is no substantial difference between a #callables that accepts a block and uses .each, and the current #callable version that uses .map and returns an array.

Comparing the following implementations:

    def append1(*callbacks, &block)
      callbacks.push block if block_given?
      callbacks.each do |c|
        @chain.push Factory.fabricate(c)
      end

      @chain.uniq!
    end

    def append2(*callbacks, &block)
      callables(callbacks, block) do |callable|
        @chain.push callable
      end

      @chain.uniq!
    end

Performance are equivalent. The 1.0x decrease is caused by the previous run and GC.

    ➜  lotus--utils git:(chain-append) ✗ ruby bm.rb
    Calculating -------------------------------------
                   push1    99.000  i/100ms
                   push2   109.000  i/100ms
    -------------------------------------------------
                   push1    398.513  (±18.1%) i/s -      1.980k
                   push2    389.637  (±20.5%) i/s -      1.962k

    Comparison:
                   push1:      398.5 i/s
                   push2:      389.6 i/s - 1.02x slower

    ➜  lotus--utils git:(chain-append) ✗ ruby bm.rb
    Calculating -------------------------------------
                   push2   101.000  i/100ms
                   push1   111.000  i/100ms
    -------------------------------------------------
                   push2    426.787  (±23.7%) i/s -      2.121k in   5.254565s
                   push1    400.473  (±20.2%) i/s -      1.998k

    Comparison:
                   push2:      426.8 i/s
                   push1:      400.5 i/s - 1.07x slower
Pull Request #52: Chain append/prepend

372 of 387 relevant lines covered (96.12%)

10.33 hits per line

Source Files on job 236.6 (2.1.4)
  • Tree
  • List 0
  • Changed 0
  • Source Changed 0
  • Coverage Changed 0
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Build 236
  • Travis Job 236.6
  • 92c4692d on github
  • Next Job for 2.1.4 on master (#237.6)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc