Skip to main content
added 929 characters in body
Source Link
Stéphane Chazelas
  • 587k
  • 96
  • 1.1k
  • 1.7k

For the sample now added to your question:

perl -MText::CSV -ne '
  if (/^(\S+)\s+(real)\s+(\S+)\s+(user)\s+(\S+)\s+(sys)/) {
    push @header, $2,$4,$6;
    push @values, $1,$3,$5;
  } elsif (/^\s*(\d+)\s+(.*)/) {
    push @header, $2;
    push @values, $1;
  }
  END {
    $csv = Text::CSV->new;
    $csv->say(*STDOUT, \@header);
    $csv->say(*STDOUT, \@values);
  }'

Which gives:

real,user,sys,"maximum resident set size","average shared memory size","average unshared data size","average unshared stack size","page reclaims","page faults",swaps,"block input operations","block output operations","messages sent","messages received","signals received","voluntary context switches","involuntary context switches","instructions retired","cycles elapsed","peak memory footprint"
57.03,212.49,16.24,88588288,0,0,0,5531,2,0,0,0,0,0,0,1,3337714,2273379580064,693450611012,87999936

For the sample now added to your question:

perl -MText::CSV -ne '
  if (/^(\S+)\s+(real)\s+(\S+)\s+(user)\s+(\S+)\s+(sys)/) {
    push @header, $2,$4,$6;
    push @values, $1,$3,$5;
  } elsif (/^\s*(\d+)\s+(.*)/) {
    push @header, $2;
    push @values, $1;
  }
  END {
    $csv = Text::CSV->new;
    $csv->say(*STDOUT, \@header);
    $csv->say(*STDOUT, \@values);
  }'

Which gives:

real,user,sys,"maximum resident set size","average shared memory size","average unshared data size","average unshared stack size","page reclaims","page faults",swaps,"block input operations","block output operations","messages sent","messages received","signals received","voluntary context switches","involuntary context switches","instructions retired","cycles elapsed","peak memory footprint"
57.03,212.49,16.24,88588288,0,0,0,5531,2,0,0,0,0,0,0,1,3337714,2273379580064,693450611012,87999936
the option seemed to get a bit lost behind the parenthetical, maybe it'd be a bit clearer this way
Source Link
ilkkachu
  • 148.2k
  • 16
  • 268
  • 441

format like that of the GNU standalone time -v with the GNU standalone utility (not the time builtin of the GNU shell) with -v may just be a matter of piping to:

format like that of the GNU standalone time utility (not the time builtin of the GNU shell) with -v may just be a matter of piping to:

format like that of time -v with the GNU standalone utility (not the time builtin of the GNU shell) may just be a matter of piping to:

added 37 characters in body
Source Link
Stéphane Chazelas
  • 587k
  • 96
  • 1.1k
  • 1.7k

If it's more like the format seen on the macos time(1) man page. for /usr/bin/time -l -h -p sleep 5:

If it's more like the format seen on the macos time(1) man page.

If it's more like the format seen on the macos time(1) man page for /usr/bin/time -l -h -p sleep 5:

added 976 characters in body
Source Link
Stéphane Chazelas
  • 587k
  • 96
  • 1.1k
  • 1.7k
Loading
added 1747 characters in body
Source Link
Stéphane Chazelas
  • 587k
  • 96
  • 1.1k
  • 1.7k
Loading
Source Link
Stéphane Chazelas
  • 587k
  • 96
  • 1.1k
  • 1.7k
Loading