title: Elapsed time of a job?
body: <p>I've put some code together to do my work. It works fine but it needs to work every 4 or 5 secs. So taking account into 4-5secs rule I have added the below code into my existing code.</p>
  
  <pre><code>#my code starts
  import time, json, requests
  start = time.process_time()
  
  --- def 2 functions and do something with them ---
  
  while True:
     with open('out.txt', 'a') as f:
          print("the result") +
                time.strftime('%Y-%m-%d %H:%M:%S',
                              time.localtime(time.time())), file=f)
    print(time.process_time() - start)
    time.sleep(2)
  </code></pre>
  
  <p>With this added code I am defining a variable called <code>start</code> at the beginning and deduct this variable from the current time at the end with <code>time.process_time() - start</code>. This way I aim to calculate how many secs have passed since the beginning. As a result of this code here:</p>
  
  <pre><code>print(time.process_time() - start)
  </code></pre>
  
  <p>I see a 1.1 secs average time on my terminal window.</p>
  
  <p>So after 2 secs of sleep time this code runs again that takes 1.1 avg. to complete and appends the new result and current time to the <code>out.txt</code> file.</p>
  
  <p>My question is:</p>
  
  <p>I expect the time at the end of the line in out.txt 3.1 secs greater than the previous one (2 secs sleep time plus 1.1 run time) but it gives me 10 secs difference between lines which I can't understand.</p>
  
  <p>Why do I get 10 secs difference between the two results, 
  and how can I reduce this to 3.1 secs?</p>