How to count elapsed time on Python
Question: I have the following code:

    
    
    def base(nomor)
        day = localtime.tm_wday
        time = localtime.tm_hour
        no = str(nomor)
        dosen = cek_dosen(no)
        if dosen == 'null':
            no_dosen()
        elif dosen != 'null':
            ada_dosen()
            matkul = cek_jadwal(day,time,dosen)
            if matkul == 'null':
                no_jadwal()
            elif matkul != 'null':
                ada_jadwal()
                pertemuan = cek_pertemuan(matkul)
                print pertemuan
                if pertemuan > 1:
                    cek_before(pertemuan)
                    filename = ''.join([dosen, matkul, str(pertemuan), ".pptx"])
                else:
                    filename = ''.join([dosen, matkul, str(pertemuan), ".pptx"])
                grabfile(filename)
                os.system(''.join(["loimpress ",filename]))
                pertemuan = pertemuan + 1
                update_pertemuan(pertemuan,matkul)
    
    
        mulai()
    
    
    if __name__ == '__main__':
      mulai()
      while True: 
        data = port.read()
        count += 1
        if count == 1:
            if str(data) != start:
                nomor = ''
                count = 0
        elif 2 <= count <= 13:
            nomor = nomor + str(data)
        elif count == 16 and str(data) == stop:
            base(nomor)
            nomor = ''
            count = 0
    

I want to count time elapse from after `data = port.read()` until after
`grabfile(filename)`. I've used `start = time.time()` after `data = port.read`
and `end = time.time()` after `grabfile`, `time = end - start`, but it stuck
after `data = port.read()` so I use Ctrl + C to stop that. If I put `start =
time.time()` after `no = str(nomor)`, I get `Attribute Error : 'int' object
has no attribute 'time'`.

How do I count the elapsed time?


Answer: 
    from time import clock
    
    start = clock()
    ...
    print "Time taken = %.5f" % (clock() - start)
    

