Score:0

How can I always measure the execution time of a terminal process?

pg flag

I'm trying to make the terminal always display the execution time of a process that I call via the command line (i.e., I want to find out how long it takes to for the process to finish).

I know that if you type time before the command, at the end it will display the execution time, but the idea is not to type anything but the command and receive the execution time at the end if possible.

hr flag
Perhaps this will be helpful: [How can I automatically time commands in bash?](https://askubuntu.com/questions/205974/how-can-i-automatically-time-commands-in-bash)
Score:0
jp flag

Use tcsh and set time

A very easy method to time each command is to install and use the shell tcsh (instead of bash which is standard in Ubuntu) and set the variable time,

tester@my-laptop:~$ sudo apt install tcsh

tester@my-laptop:~$ tcsh
my-laptop:~> set time
my-laptop:~> sleep 3
0.003u 0.000s 0:03.00 0.0%      0+0k 0+0io 0pf+0w
my-laptop:~> 

Show the wall-time when each prompt was printed in bash

Maybe it would be enough for you to have a clock in the prompt, so that you see the 'wall-time' when the command finished and the terminal window returned to prompt?

A crude prompt to enter interactively for this purpose would be

PS1='$(date '+%T') $ '

or to add to the current prompt

PS1='$(date '+%T') '"$PS1"

Reset to the standard prompt with

source ~/.bashrc
Score:-2
td flag

run the command with time(which is a shell keyword aka a command) like this. time foobar or time sleep 1. anorthor example is

#!/bin/bash
#how big is your file system
time tree /
Pierre ALBARÈDE avatar
sc flag
Maybe write a small script with `time` inside.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.