Created
February 16, 2016 02:46
-
-
Save ateliercw/358d96bfba3c1f05f5b8 to your computer and use it in GitHub Desktop.
Parses xcode timing data to json
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 'json' | |
def parse_line(line) | |
units = line.split("\t") | |
hash = {} | |
hash[:time] = parse_time(units[0]) | |
hash[:file] = parse_file(units[1]) | |
hash[:function] = units[2] | |
hash | |
end | |
def parse_time(time) | |
time.chomp("ms").to_f | |
end | |
def parse_file(file) | |
hash = {} | |
components = file.split(':') | |
if components.count >= 3 | |
hash[:col] = components.pop.to_i | |
hash[:line] = components.pop.to_i | |
end | |
hash[:path] = components.join(':') | |
hash | |
end | |
lines = STDIN.read.split("\n").map { |line| parse_line(line) } | |
puts JSON.pretty_generate(lines) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment