Для измерения времени выполнения программы в Ubuntu есть специальные команды.
$ time python yourprogram.py
Code language: Bash (bash)
real 0m0,102s
user 0m0,094s
sys 0m0,008s
Ещё есть вариант команды с более подробным выводом.
$ /usr/bin/time -v python yourprogram.py'
Code language: Bash (bash)
Command being timed: "python yourprogram.py"
User time (seconds): 0.09
System time (seconds): 0.00
Percent of CPU this job got: 98%
Elapsed (wall clock) time (h:mm:ss or m:ss): 0:00.09
Average shared text size (kbytes): 0
Average unshared data size (kbytes): 0
Average stack size (kbytes): 0
Average total size (kbytes): 0
Maximum resident set size (kbytes): 17552
Average resident set size (kbytes): 0
Major (requiring I/O) page faults: 0
Minor (reclaiming a frame) page faults: 3070
Voluntary context switches: 1
Involuntary context switches: 9
Swaps: 0
File system inputs: 0
File system outputs: 0
Socket messages sent: 0
Socket messages received: 0
Signals delivered: 0
Page size (bytes): 4096
Exit status: 0
Code language: AngelScript (angelscript)
Путь /usr/bin/time нужно указывать обязательно, иначе запустится другая команда time.