Optimal Checkpointing Period: Time vs. Energy