fork download
  1. #!/usr/bin/perl -w
  2. use strict;
  3. {
  4. my @result_a = ( [qw( element before after diff )] );
  5. foreach my $elem (
  6. '1',
  7. 'i',
  8. 'sprintf("%d",i)',
  9. 'sprintf("%d",i) + 0',
  10. 'sprintf("%d",i) ""',
  11. ) {
  12. my $source = "function cb( i){ return $elem;}";
  13. open( my $fh,'-|','gawk','--source',$source,'-f','b.awk') || die( $!);
  14. my @r_a = <$fh>;
  15. my ( $before,$after) = map { ( split(' ',$r_a[$_]))[1] } 1,3;
  16. push( @result_a,[$elem,$before,$after,$after - $before]);
  17. }
  18. printf("%-25s %7s %7s %7s\n",@{ $_ }) foreach @result_a;
  19. }
  20.  
  21. # b.awk
  22.  
  23. function do_ps(){ system("ps p $PPID o pid,sz,args") }
  24. BEGIN {
  25. do_ps();
  26. for ( i = 0; i < 1000000; i++){ a[i] = cb(i) }
  27. do_ps();
  28. }
  29.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty