Skip to content

Instantly share code, notes, and snippets.

@ateliercw
Created February 16, 2016 02:46
Show Gist options
  • Save ateliercw/358d96bfba3c1f05f5b8 to your computer and use it in GitHub Desktop.
Save ateliercw/358d96bfba3c1f05f5b8 to your computer and use it in GitHub Desktop.
Parses xcode timing data to json
#!/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