Explanation:
use zgrep to get the line starting with time or mem
use sed to convert multiple spaces to single space
use sed again to get only the line containing Memory or time
use sed the last time to merge the 2 lines