Demonstrate how to time an event.
% event_timer_demo --help # The "--help" flag gives an example. event_timer_demo: Script to demonstarte how I use routine "dspit" and "dsep" to time an event (like the time to run a code). Usage: event_timer_demo N arg1 - run in debug mode (Y/N) NOTE: Only good to integer seconds EXAMPLE: % event_timer_demo N a 1 Thu Sep 27 16:08:35 UTC 2018 You can wait for some time interval. After you hit a return, that time interval will be measured and reported. Enter any key to continue: a 2 Thu Sep 27 16:09:05 UTC 2018 Time interval = 30.000000 seconds Here is the full script ========================================================================== #!/bin/bash # Check command line arguments if [ -z "$1" ] then printf "Usage: event_timer_demo N \n" printf "arg1 - run in debug mode (Y/N)\n" printf "NOTE: Only good to integer seconds \n" exit fi if [ $1 = "--help" ] then show_help event_timer_demo exit fi # rename arguments debug="$1" if [ $debug = "Y" ] then printf "Debug flag is ON in event_timer_demo. \n" fi dspit a 1 dsep tstamp.a_1 > Time.Start printf "\nYou can wait for some time interval. \n" printf "After you hit a return, that time interval will be measured and reported. \n" message_and_read s dspit a 2 dsep tstamp.a_2 > Time.End read t1 < Time.Start read t2 < Time.End fpmath.sh $t2 - $t1 > junk.100 read time < junk.100 printf "\n\n\tTime interval = $time seconds \n" if [ $debug = "Y" ] then exit fi # make a last clean up \rm -f dsep.out junk.100 pars.in Time.End Time.Start tstamp.a_1 tstamp.a_2 ==========================================================================