Skip to content
shellmap

timesShow accumulated CPU time used by the shell and its children across all 5 shells

Equivalents in every shell

Bashunix
times

Builtin (POSIX). Prints two lines: `user system` for the shell itself, then `user system` for all completed CHILDREN. Times are CUMULATIVE since the shell started and reset only when a new shell is spawned. No options, no per-command timing.

Zshunix
times

Builtin, same POSIX semantics and output as bash. Zsh also exposes `$SECONDS` (elapsed wall clock since shell start) and the `time` keyword for per-command timing — `times` is the only way to get cumulative totals split between shell and children.

Fishunix
time some_command

Fish does NOT implement POSIX `times`. The closest is `time some_command` (per-pipeline timing via the `time` keyword) or polling `(string split " " (cat /proc/$fish_pid/stat))[14..17]` on Linux for raw clock ticks. There is no single-command cumulative summary.

PowerShellwindows
(Get-Process -Id $PID).CPU

Returns the host process's total CPU seconds (user + kernel, accumulated). For separate user vs. kernel splits, `.UserProcessorTime` and `.PrivilegedProcessorTime`. Child processes are NOT included unless you sum descendants yourself.

cmd.exewindows
wmic process get Name,UserModeTime,KernelModeTime

Cmd has no equivalent built-in. WMIC reports CPU time per process (100ns units). The cmd `time` keyword SETS the system clock instead of measuring. For accurate per-shell totals, shell out to PowerShell `(Get-Process -Id $PID).CPU` from inside cmd.

Worked examples

Print accumulated CPU time used so far

Bash
times
Zsh
times
PowerShell
(Get-Process -Id $PID).CPU

Compare CPU spent in the shell vs. its children

Bash
times    # line 1: shell, line 2: children
Zsh
times    # line 1: shell, line 2: children
PowerShell
$p = Get-Process -Id $PID; "$($p.UserProcessorTime) user; $($p.PrivilegedProcessorTime) kernel"

Time a single command instead (not what times does)

Bash
time some_command
Zsh
time some_command
Fish
time some_command
PowerShell
Measure-Command { some_command }

Gotchas

  • `times` reports CUMULATIVE time since the shell started — it is NOT a per-command stopwatch. For per-command timing use the `time` keyword. Scripts that print `times` before and after a command and subtract get a noisy answer dominated by shell overhead, not the command.
  • The two output lines are `shell-user shell-system` then `children-user children-system`. Order matters and the format is FIXED — no `times -p` or `--format` option. Parsing scripts must handle the exact `Xm Ys.NNNs` layout (one space between user and system; no trailing newline on some shells).
  • Fish has no `times` builtin and no plan to add one — its maintainers consider per-command `time` sufficient. Bash / zsh scripts ported to fish that rely on `times` for accounting must be reworked to use `/usr/bin/time -v` or sum `getrusage` from a wrapper.
  • PowerShell `(Get-Process -Id $PID).CPU` measures only the CURRENT process. Bash `times` ALSO accumulates from already-reaped children — pwsh has no automatic accumulator. Sum descendants manually with `Get-Process | ? Parent -eq $PID` or use `Get-Counter` for system-wide totals.
  • Cmd `time` SETS the wall clock instead of measuring CPU time — running `time` opens the interactive clock-set prompt. Always reach for PowerShell or WMIC for any CPU-time question on cmd; the legacy shell has no native facility.

WSL & PowerShell Core notes

pwsh`Get-Process` and `.CPU` work identically on Windows, Linux, and macOS pwsh — internally they read `/proc/PID/stat` on Linux and `ps` / `task_info` on macOS, then return seconds as a `[double]`. The cumulative-children semantics of bash `times` have no direct cross-platform pwsh equivalent.
WSLWSL `times` measures the Linux-side process tree only; it cannot see Windows-side cousins spawned via interop. A `cmd.exe /c calc.exe` launched from WSL counts as a child while it RUNS but disappears from `times` once interop completes — Windows accounting lives in `Get-Process` on the Windows side.

Related commands