I have read the documentation of the timeit module and also you can pass a function (without arguments) to it (e.g. https://stackoverflow.com/questions/5086430/how-to-pass-parameters-of-a-func...).
My needs are: - simple way to instrument my code to log time for a function or a code block (I am not writing a specific script to time/benchmark a specific code) - have the timing sent to some logger - be the less intrusive possible
With the Timer proposed here above (bad naming as Timer already exists in the timeit module, maybe Clocker ?), I can simply: - decorate a function with it and I am done - wrap an existing code with it as context manager
I thank you for the suggestions already made but they do not fit in my need/use case in a nice/pythonic way.