0

I'm trying to make a python counter for my program. It must be seen countering by the terminal with the python program.py command.

It has to be run in the user's terminal for the user to know the execution time of the code.

In this example here I used a basic arp command just to test with the code I got here on the site, but it returns 0 ; 0 : 0 ; 0

import subprocess as sp
import time

def stopWatch(value):
    '''From seconds to Days;Hours:Minutes;Seconds'''

    valueD = (((value/365)/24)/60)
    Days = int (valueD)

    valueH = (valueD-Days)*365
    Hours = int(valueH)

    valueM = (valueH - Hours)*24
    Minutes = int(valueM)

    valueS = (valueM - Minutes)*60
    Seconds = int(valueS)


    print(Days,";",Hours,":",Minutes,";",Seconds)




start = time.time() # What in other posts is described is

vulns_output = sp.getoutput("arp -a")

end = time.time()
stopWatch(end-start) #Use then my code

What is wrong or some other solution? I would like it to show in minutes, seconds and hours and not just milliseconds like I found on the internet.

Lucas Fernandes
  • 1,256
  • 2
  • 8
  • 10
  • Check [this post and its answers](https://stackoverflow.com/q/538666/17457042). Notice that you have one conversion to years and are missing one conversion to minutes, so you get 0 – azelcer Mar 05 '22 at 00:49

0 Answers0