The cpu command from Plan 9 does what you want: http://man.cat-v.org/plan_9/1/cpu
This talk from FOSDEM describes a Linux version of "cpu" written in Go: https://fosdem.org/2022/schedule/event/plan_9_cpu_cmd/
This talk from FOSDEM describes a Linux version of "cpu" written in Go: https://fosdem.org/2022/schedule/event/plan_9_cpu_cmd/