Skip to content

Instantly share code, notes, and snippets.

@toddsampson
Last active December 28, 2015 06:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toddsampson/7456104 to your computer and use it in GitHub Desktop.
Save toddsampson/7456104 to your computer and use it in GitHub Desktop.
Gists for Flog and to_proc_normal blog post: http://www.cloudspace.com/blog/2010/02/12/flog-and-to_proc_normal/
Rehearsal ------------------------------------
Benchmarking fruit_names_1:
4.040000 1.750000 5.790000 ( 5.852924)
Benchmarking fruit_names_2:
3.990000 2.060000 6.050000 ( 6.092260)
-------------------------- total: 11.840000sec
user system total real
Benchmarking fruit_names_1:
4.030000 1.750000 5.780000 ( 5.806661)
Benchmarking fruit_names_2:
3.980000 2.070000 6.050000 ( 6.114498)
Rehearsal ------------------------------------
Benchmarking fruit_names_1:
0.320000 0.000000 0.320000 ( 0.327978)
Benchmarking fruit_names_2:
0.190000 0.010000 0.200000 ( 0.191589)
--------------------------- total: 0.520000sec
user system total real
Benchmarking fruit_names_1:
0.320000 0.000000 0.320000 ( 0.325131)
Benchmarking fruit_names_2:
0.190000 0.000000 0.190000 ( 0.192975)
11.8: Test#fruit_names_1 test.rb:10
7.5: to_proc_normal
1.5: block_pass
1.5: fruits
1.3: map
4.6: Test#fruit_names_2 test.rb:14
1.5: fruits
1.4: assignment
1.4: name
1.3: branch
1.3: map
def fruit_names_1
fruits.map(&:name)
end
def fruit_names_2
fruits.map do |fruit|
fruit.name
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment