⚲
Project
General
Profile
Sign in
Register
Home
Projects
Help
Search
:
Ruby master
All Projects
Ruby
»
Ruby master
Overview
Activity
Roadmap
Issues
Repository
Like
Download (880 Bytes)
Bug #13167
» bench_dir_glob.rb
h.shirosaki (Hiroshi Shirosaki)
, 09/11/2017 09:58 AM
require
'benchmark/ips'
require
'fileutils'
# setup directories
ROOT
=
/mingw/
=~
RUBY_PLATFORM
?
'v:'
:
'/tmp'
BASE_DIR
=
"
#{
ROOT
}
/test/myapp/app/views/common"
FileUtils
.
mkdir_p
(
BASE_DIR
)
%w(_menu_stats.html.erb _menu_stats.en.html.erb)
.
each
do
|
path
|
FileUtils
.
touch
(
"
#{
BASE_DIR
}
/
#{
path
}
"
)
end
20
.
times
do
|
i
|
FileUtils
.
touch
(
"
#{
BASE_DIR
}
/../
#{
i
}
"
)
FileUtils
.
touch
(
"
#{
BASE_DIR
}
/
#{
i
}
"
)
end
p
BRACES_PATTERN
=
"
#{
ROOT
}
/test/myapp/app/views/common/_menu_stats{.en,}{.html,}{}{.erb,.builder,.raw,.ruby,.jbuilder,.coffee,}"
p
RECURSIVE_PATTERN
=
"
#{
ROOT
}
/test/myapp/app/views/**/_menu_stats{.en,}{.html,}{}{.erb,.builder,.raw,.ruby,.jbuilder,.coffee,}"
Benchmark
.
ips
do
|
x
|
x
.
report
(
"braces"
)
do
Dir
.
glob
(
BRACES_PATTERN
)
end
x
.
report
(
"recursive"
)
do
Dir
.
glob
(
RECURSIVE_PATTERN
)
end
end
# cleanup
FileUtils
.
rm_rf
(
"
#{
ROOT
}
/test"
)
« Previous
1
2
3
4
5
…
12
Next »
(3-3/12)
Loading...