Skip to content

Commit

Permalink
fix several file benchmarks so they do not rely on the current workin…
Browse files Browse the repository at this point in the history
…g dir to succeed
  • Loading branch information
Chuck Remes authored and headius committed Aug 24, 2011
1 parent 4b11084 commit 49a8d40
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 15 deletions.
4 changes: 2 additions & 2 deletions core/file/bench_directory.rb
@@ -1,8 +1,8 @@
require 'benchmark'
require 'benchmark/ips'

existing_dir = "./lib/ffi"
nonexistent_dir = "./lib/noexists"
existing_dir = File.dirname(__FILE__)
nonexistent_dir = File.join(__FILE__, 'noexists')

Benchmark.ips do |x|
x.report "File.directory? - true" do
Expand Down
4 changes: 2 additions & 2 deletions core/file/bench_exists.rb
@@ -1,8 +1,8 @@
require 'benchmark'
require 'benchmark/ips'

existing_file = "./lib/ffi.rb"
nonexistent_file = "./lib/noexists.rb"
existing_file = File.join(__FILE__)
nonexistent_file = File.join(__FILE__, "noexists")

Benchmark.ips do |x|
x.report "File.exists? - true" do
Expand Down
4 changes: 2 additions & 2 deletions core/file/bench_file.rb
@@ -1,8 +1,8 @@
require 'benchmark'
require 'benchmark/ips'

existing_file = "./lib/ffi.rb"
existing_dir = "./lib/ffi"
existing_file = File.join(__FILE__)
existing_dir = File.dirname(__FILE__)

Benchmark.ips do |x|
x.report "File.file? - true" do
Expand Down
4 changes: 2 additions & 2 deletions core/file/bench_fnmatch.rb
@@ -1,14 +1,14 @@
require 'benchmark'
require 'benchmark/ips'

path = "./lib/ffi/generator.rb"
path = File.join(__FILE__)

Benchmark.ips do |x|
x.report "File.fnmatch plain" do
File.fnmatch(path, path)
end

x.report "File.fnmatch *" do
File.fnmatch("./lib/ffi/*.rb", path)
File.fnmatch("*.rb", path)
end
end
2 changes: 1 addition & 1 deletion core/file/bench_new.rb
@@ -1,7 +1,7 @@
require 'benchmark'
require 'benchmark/ips'

existing_file = "./lib/ffi.rb"
existing_file = File.join(__FILE__)

Benchmark.ips do |x|
x.report "File.new" do
Expand Down
8 changes: 3 additions & 5 deletions core/file/bench_read.rb
@@ -1,11 +1,9 @@
require 'benchmark'
require 'benchmark/ips'

small_file = 'benchmark/core/file/small.txt'
medium_file = 'benchmark/core/file/medium.txt'
large_file = 'benchmark/core/file/large.txt'

existing_file = "./lib/ffi.rb"
small_file = File.join(__FILE__, 'small.txt')
medium_file = File.join(__FILE__, 'medium.txt')
large_file = File.join(__FILE__, 'large.txt')

Benchmark.ips do |x|
x.report "File.read a small file" do
Expand Down
2 changes: 1 addition & 1 deletion core/file/bench_stat.rb
@@ -1,7 +1,7 @@
require 'benchmark'
require 'benchmark/ips'

existing_file = "./lib/ffi.rb"
existing_file = File.join(__FILE__)

Benchmark.ips do |x|
x.report "File.stat" do
Expand Down

0 comments on commit 49a8d40

Please sign in to comment.