I am new at android development. I wanted to profile the performance of my application. So I have generated a log file(.trace) by adding the following code -
`// start tracing to "/sdcard/calc.trace"
Debug.startMethodTracing("calc");
// ...
// stop tracing
Debug.stopMethodTracing();`
Now, I have a calc.trace file. But I want for parse this file into sql format so that I can use advance queries to bring out information from the data. How can I do that?
You can parse the (.)trace file with the following ruby code that uses regex to parse the data into (.)sql file. It also provides a query to insert the data into your choice of SQL database.
But before that use the following command to convert the binary trace log into a txt file
/pathTotraceview/trceview -r filename.trace > filename.txt
Then save and run the following code.
#!/usr/bin/env ruby
@values = Array.new
STDIN.read.split("\n").each do |a|
if a =~ /(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s([\w+.$]+)/
id = $1
tstart = $2
tend = $3
gstart = $4
gend = $5
excl = $6
incl = $7
meth = $8
@values << "(#{id},#{tstart},#{tend},#{gstart},#{gend},#{excl},#{incl},'#{meth}')"
end
end
puts "INSERT INTO table_name(pid,tstart,tend,gstart,gend,excl,incl,meth) values"
puts "#{@values.join(" , ")};"
To purse with this file store it in your work directory as toSQL.rb or any other name and use the following command in your terminal to generate sql dump:
cat traceFileName.txt | ./toSQL.rb > fileName.sql