Link to home
Start Free TrialLog in
Avatar of kewlclassic
kewlclassic

asked on

how can I insert time in my python script?

I need to insert time in my deployment script. What command should i put so that i can get a total duration of time it took for the deployment? Means, i need to have the start time and end in my script and duration is took for the completed deployment process.

Any help will be appreciated.

Thanks much
Kewl
ASKER CERTIFIED SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pepr
pepr

@kaufmed: It seems that it can be used this way only on Windows. For Unix it seems that the two values should be subtracted. I did not try, but the doc says:
   On Unix, return the current processor time as a floating point number expressed in seconds. The precision, and in fact the very definition of the meaning of “processor time”, depends on that of the C function of the same name, but in any case, this is the function to use for benchmarking Python or timing algorithms.

    On Windows, this function returns wall-clock seconds elapsed since the first call to this function, as a floating point number, based on the Win32 function QueryPerformanceCounter(). The resolution is typically better than one microsecond.
I confess that I ran that code on Windows. When I started the code, I fully expected to have to subtract, but when I ran it, I (of course) noticed the Windows behavior. So I ran with it!

A good point to keep in consideration for sure  = )
:) The  reason why I have noticed is that it was surprising for me. Because of that I have looked into the documentation. It is a bit strange that the function behaves that differently in both systems. The good thing is that it uses the QueryPerformanceCounter (i.e. high resolution).
Avatar of kewlclassic

ASKER

Thanks guys I appreciate your help on this.