Skip to content

Commit

Permalink
Merge pull request #111 from jhawthorn/output_directory
Browse files Browse the repository at this point in the history
Change default output to current directory
  • Loading branch information
jhawthorn authored Nov 26, 2024
2 parents 7e168a7 + c9e6a27 commit 80fd2e8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
3 changes: 3 additions & 0 deletions exe/vernier
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ FLAGS:
o.on('--output [FILENAME]', String, "output filename") do |s|
options[:output] = s
end
o.on('--output-dir [DIRECTORY]', String, "output directory (default .)") do |s|
options[:output_dir] = s
end
o.on('--interval [MICROSECONDS]', Integer, "sampling interval (default 500)") do |i|
options[:interval] = i
end
Expand Down
18 changes: 17 additions & 1 deletion lib/vernier/autorun.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,24 @@ def self.start
def self.stop
result = @collector.stop
@collector = nil

output_path = options[:output]
output_path ||= Tempfile.create(["profile", ".vernier.json.gz"]).path
unless output_path
output_dir = options[:output_dir]
unless output_dir
if File.writable?(".")
output_dir = "."
else
output_dir = Dir.tmpdir
end
end
prefix = "profile-"
timestamp = Time.now.strftime("%Y%m%d-%H%M%S")
suffix = ".vernier.json.gz"

output_path = File.expand_path("#{output_dir}/#{prefix}#{timestamp}-#{$$}#{suffix}")
end

result.write(out: output_path)

STDERR.puts(result.inspect)
Expand Down

0 comments on commit 80fd2e8

Please sign in to comment.