summaryrefslogtreecommitdiff
path: root/benchmark/realpath.yml
blob: 90a029d5b982bada4e136fcf37dd8f9a632c4fa7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
prelude: |
  f = File
  pwd = Dir.pwd
  Dir.mkdir('b') unless f.directory?('b')
  f.write('b/a', '') unless f.file?('b/a')

  relative = 'b/a'
  absolute = File.join(pwd, relative)
  dir = 'b'
  file = 'a'

  relative_dir = 'b/c'
  absolute_dir = File.join(pwd, relative_dir)
  file_dir = 'c'
benchmark:
  relative_nil: "f.realpath(relative, nil)"
  absolute_nil: "f.realpath(absolute, nil)"
  relative_relative: "f.realpath(file, dir)"
  absolute_relative: "f.realpath(absolute, dir)"
  relative_absolute: "f.realpath(relative, pwd)"
  relative_nil_dir: "f.realdirpath(relative_dir, nil)"
  absolute_nil_dir: "f.realdirpath(absolute_dir, nil)"
  relative_relative_dir: "f.realdirpath(file_dir, dir)"
  absolute_relative_dir: "f.realdirpath(absolute_dir, dir)"
  relative_absolute_dir: "f.realdirpath(relative_dir, pwd)"
  relative_nil_notexist: "f.realpath(relative_dir, nil) rescue nil"
  absolute_nil_notexist: "f.realpath(absolute_dir, nil) rescue nil"
  relative_relative_notexist: "f.realpath(file_dir, dir) rescue nil"
  absolute_relative_notexist: "f.realpath(absolute_dir, dir) rescue nil"
  relative_absolute_notexist: "f.realpath(relative_dir, pwd) rescue nil"