I’ve got a C program.
Is there a bash command which could measure with high precision:
- the time when the instructions of the program are executed;
- the time when the system calls instructions the program uses are executed;
- the time consumed by the system calls (input/output operations, memory allocations etc.) themselves.
I also have a script that runs the program multiple times:
#!/usr/bin/env bash
project=database_binary_and_hash_search
build_dir=../database_binary_and_hash_search/build
bin_dir=$build_dir/bin
executable=$bin_dir/$project
file_name=search_speed_test_file
num_of_entries_in_file=1000
every_n_entry_to_print=100
for (( i=1; i<=$num_of_entries_in_file; i++ )); do
item_name=$(./random_str $i)
if (( i % $every_n_entry_to_print == 0 )); then
echo "$item_name"
fi
$executable $file_name add $item_name
done
Is it possible to measure the sum of the time the program was executed?