time a command
How long a command takes, and how much memory and processor it used.
Steps
-
time commandreal is the clock time; user and sys, the processor's
-
/usr/bin/time -v commandalso its peak memory (GNU time)
-
hyperfine 'command'run it many times for a fair figure (hyperfine)
Notes
- real much bigger than user + sys means it was waiting: the disk, the network or you.
Commands used
timehyperfine
Each has a page in lore: lore time opens it.
Related recipes
- ask for input in a scriptAsk yes or no, read a password without showing it, or wait for an answer with a time limit.
- check if a file or folder existsTest in a script whether a path exists, is a file, a folder, empty or runnable.
- check if a string contains a textTest in a script whether a string contains, starts with or matches something.
- count lines of codeHow many lines of code a project has, in total and by language.