Created
January 15, 2016 23:07
-
-
Save brianmichel/639368005a99fc0a1d73 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'pathname' | |
exit 1 unless ARGV[0] | |
full_file_path = File.expand_path("#{ARGV[0]}") | |
puts "got file path: #{full_file_path}" | |
exit 1 unless File.extname(full_file_path) == '.xcactivitylog' | |
puts "it's an activity log!" | |
basename = Pathname.new("#{full_file_path}").basename.to_s | |
puts "base: #{basename}" | |
gzipped_file_name = basename + '.gz' | |
puts "gzipped: #{gzipped_file_name}" | |
tmp_gzipped_file_name = "/tmp/#{gzipped_file_name}" | |
puts "tmp: #{tmp_gzipped_file_name}" | |
unzipped_base_file_name = "/tmp/#{basename}" | |
puts "unzipped: #{unzipped_base_file_name}" | |
# Make a copy of the file with the gzip extension | |
copy_status = `cp "#{full_file_path}" "#{tmp_gzipped_file_name}"` | |
unzip_status = `gzip -d #{tmp_gzipped_file_name}` | |
analysis_status = `cat #{unzipped_base_file_name} | grep "[1-9].[0-9]ms" | sort -nr > "#{basename}-swift-analysis.txt"` | |
puts "Copy Status: #{copy_status}, Unzip Status: #{unzip_status}, Analysis Status: #{analysis_status}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment