Howto time function execution with Python

I recently had a requirement to test performance of a function call in a python script I have written. After searching the web, I finally stumbled upon a python module called timeit. After searching how to use it, I stumbled upon this blog post that explains how to wrap a function call and execute that function with timeit several times to get average execution time.
So, here's the code that I've taken from above mentioned blog post.

Fun with Python and Gmail

In this article, I will show you how to log in to a Gmail account via IMAP and search your inbox for a mail.

Why you ask? Well, for me it was needed for one of my automation tasks for FamilyPoint application we are working on. When an ivitation is sent, we needed an automatic way of getting the invite code and register an account with that code...