⚲
Project
General
Profile
Sign in
Register
Home
Projects
Help
Search
:
Ruby master
All Projects
Ruby
»
Ruby master
Overview
Activity
Roadmap
Issues
Repository
Like
Download (428 Bytes)
Feature #6183
» lazy_test.rb
gregolsen (Innokenty Mikhailov)
, 03/21/2012 10:24 PM
require
'benchmark'
N
=
100
def
test_lazy
(
array
)
Benchmark
.
bm
(
10
)
do
|
r
|
r
.
report
(
'Lazy:'
)
do
N
.
times
do
array
.
lazy
.
map
{
|
x
|
x
*
10
}.
map
{
|
x
|
x
*
100
}.
map
{
|
x
|
x
*
100
}.
each
{
|
x
|
x
*
1000
}
end
end
r
.
report
(
'Normal:'
)
do
N
.
times
do
array
.
map
{
|
x
|
x
*
10
}.
map
{
|
x
|
x
*
100
}.
map
{
|
x
|
x
*
100
}.
each
{
|
x
|
x
*
1000
}
end
end
end
end
test_lazy
([
1
,
2
,
3
]
*
1000
)
« Previous
1
2
3
…
6
Next »
(1-1/6)
Loading...