I have multiple functions, where each function is designed to perform a particular task. For the sake of an example, suppose I want to prepare lunch. Possible functions for this task can be, collect_vege_images() remove_duplicates() and count_veges_in_multiple_plates().
Problem:
I want to generate a dataframe where each row records the function start time, end time and elapsed time.
Iteration   image count   Function            start time       end time   elapse time
1           200           collect_vege_images  11.00           11.10       0.10
            200           remove_duplicates    11.10           11.15       0.5
            100 count_veges_in_multiple_plates  11.16          11.20       0.4
2           300           collect_vege_images   11.21          11.31       0.10
            150           remove_duplicates     11.31          11.35       0.5
            50  count_veges_in_multiple_plates  11.35          11.39       0.4
What I have tried so far
I have written both functions, however, I'm not able to get the desired output that I want. The code is given below as well as the output its generating. Needless to state, I've already looked at similar questions 1, 2, 3,4, but most are related to timing individual functions only. Looking for a simple solution as I'm beginner in python programming.
import os
import pandas as pd
import time
    
VEGE_SOURCE = r'\\path to vegetable images'
VEGE_COUNT = 5
VEGE_DST = r'\\path to storing vegetable images'
LOG_FILE_NAME = 'vege_log.csv'
plates = 5
CYCLES=5
counter = ([] for i in range(7))
VEGEID = 'Potato'
def collect_vege_images(VEGE_SOURCE):
    plate = os.listdir(VEGE_SOURCE)
    if len(plate) == 0:
        print("vege source is empty: ", folder)
    else:
        for i in range(VEGE_COUNT):
            vege = plate[0]
            curr_vege = VEGE_SOURCE + '\\' + vege
            shutil.move(curr_vege, VEGE_DST)
            plate.pop(0)
    return
def count_veges_in_multiple_plates(plates):
    N = 0
    for root, dirname, files in os.walk(plates):
        # print(files)
        file_count = len(files)
        vege_img_count += file_count
    return vege_img_count
    
if __name__ == __main__:
    collect_vege_images(VEGE_SOURCE)
    img_count = count_veges_in_multiple_plates(plates=5)
    for i in range(CYCLES):
        print("Round # ", i)
        counter.append(i)
        # print("counter: ", counter)
        start_time = time.process_time()
        collect_vege_images(VEGE_SOURCE)
        count_veges_in_multiple_plates(plates=5)
        end_time = time.process_time()
        elapse_time = round((end_time - start_time), 2)
        fun = collect_vege_images.__name__
        df = pd.DataFrame(
            {'vegeid': VEGEID, 'imgcnt': img_count, 'func': fun, 'start_time': start_time, 'end_time': end_time,
             'elapse_time': elapse_time}, index=[0])
        print(df)
Current code output given below
Round #  1
Moving files...
122 files moved!
iteration  imgcnt   func                    start_time  end_time  elapse_time
   0         122    collect_vege_images     22.10       22.15         0.5
Round #  2
Moving files...
198 files moved!
iteration  imgcnt   func                    start_time  end_time  elapse_time
   1         122    collect_vege_images     22.15       22.19         0.04
 
     
    