I have file with content:
file.txt:
Iteration 1
RAM: +456ms
Cache: +142ms (total +417ms)
Iteration 2
Spec: +152ms
Cache: +149ms (total +413ms)
Iter
This might work for you (GNU sed):
sed -E '/:/!d;s/.([0-9]+).*/\1/;H;x;s/((\n\S+) \S+)(.*)\2(.*)/\1\4\3/;h;$!d;x;s/.//' file
Any lines other than those that contain a :
are noise, so delete them.
Remove all but the key, a space and the first set of integers from each line.
Append the result to the hold space.
Using pattern matching, gather up like keys data and retain in the hold space.
Delete all but the last line.
At the end of file, swap to the hold space, remove the introduced newline and print the result.