Performance Comparison of libdsepio_read and read_trk Functions

This script benchmarks the performance of two functions, libdsepioread and readtrk, used for reading tracking data from file paths. It measures the execution time for reading the same track file multiple times using both Python loops and leveraging a library possibly written in C++. Additionally, it employs the pandas library to organize the timing results into a dataframe and outputs these results into a CSV file. Finally, it prints the execution timings for each function to the console, providing insight into which method is more efficient for reading track data files.

from pysep.io.trk.read import libdsepio_read
from pysep.io.trk import read_trk
from datetime import datetime
import numpy as np
import pandas as pd
 
path = 'example.track'
 
# Total = np.linspace(1, 100, 25)
#
# print("========= Python Loop Test ==========")
# PythonTimes = list()
# for t in Total:
#     start = datetime.now()
#     for i in range(int(t)):
#         n  = libdsepio_read([path], 60)
#     end = datetime.now()
#     PythonTimes.append((end-start).total_seconds())
#
# print("========= C++ Loop Test ===========")
# Ctimes = list()
# for t in Total:
#     start = datetime.now()
#     n  = libdsepio_read([path]*int(t), 60)
#     end = datetime.now()
#     Ctimes.append((end-start).total_seconds())
#
# ActualTotal = list()
# for t in Total:
#     ActualTotal.append(int(t))
#
# payload = {'files':ActualTotal, 'PyTime':PythonTimes, 'CTime':Ctimes}
# df = pd.DataFrame(payload)
# df.to_csv('res.csv', index=False)
print('=========== libdsepio timeing ==============')
start = datetime.now()
n = libdsepio_read([path]*50, 60)
end = datetime.now()
print(f"Took: {(end-start).total_seconds()} s")
print('=========== read_trk timeing ==============')
start = datetime.now()
n,m = read_trk([path]*50)
end = datetime.now()
print(f"Took: {(end-start).total_seconds()} s")
# print(type(n))