time and % time added in printing.

You should make sure `profile` is not `None` before accessing its members. The `profile` information should be printed only if `profile` is not `None`.