Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Grouping helpers should use yield instead of block

#723

Grouping helpers are using &block as parameter, yield should be used when possible so no new Procs are created.

I did some benchmark to confirm this and as you can see there is a better performance when using yield.

All tests still pass, of course.

Using yield:

Rehearsal ---------------------------------------------------------

test_split_with_block 6.100000 0.050000 6.150000 ( 6.839069)

------------------------------------------------ total: 6.150000sec

user system total real

test_split_with_block 6.120000 0.040000 6.160000 ( 7.529286)

Rehearsal ---------------------------------------------------------------------

test_in_groups_of_without_padding 4.190000 0.030000 4.220000 ( 4.498870)

------------------------------------------------------------ total: 4.220000sec

user system total real

test_in_groups_of_without_padding 4.210000 0.030000 4.240000 ( 4.789496)

Using block:

Rehearsal ---------------------------------------------------------

test_split_with_block 7.090000 0.060000 7.150000 ( 7.868116)

------------------------------------------------ total: 7.150000sec

user system total real

test_split_with_block 7.130000 0.050000 7.180000 ( 8.359386)

Rehearsal ---------------------------------------------------------------------

test_in_groups_of_without_padding 4.850000 0.030000 4.880000 ( 5.039969)

------------------------------------------------------------ total: 4.880000sec

user system total real

test_in_groups_of_without_padding 4.810000 0.030000 4.840000 ( 5.156383)

Reported by Emilio Tagua · July 29th, 2008 @ 11:09 PM

State: resolved
Milestone: none
Assigned to: Pratik Pratik
Importance: High

Activity

  1. Pratik
    Pratik
    • Assigned user set to Pratik

    July 29th, 2008 @ 11:22 PM

  2. Emilio Tagua
  3. Jeremy Kemper
    Jeremy Kemper
    • State changed from new to open
    • Milestone cleared.

    July 30th, 2008 @ 09:51 AM

  4. Repository
    Repository
    • State changed from open to resolved

    (from [2617d0dc5ced4b354bff9633bddafdf80ad5a711]) Performance: grouping helpers should use yield instead of block as argument. [#723 state:resolved]

    http://github.com/rails/rails/co...

    July 30th, 2008 @ 10:07 AM