in reply to Re: Live operations-per-second counter
in thread Live operations-per-second counter

And here is that threaded solution.
use strict; use Config; $Config{useithreads} or die "Recompile Perl with threads to run this p +rogram."; use threads; use threads::shared; use Time::HiRes qw ( time sleep); our $starttime : shared; our $linecount : shared = 0; our $running : shared = 1; sub progress { my $lasttime = $starttime; my $lastlinecount = 0; sleep(1); $| = 1; do { my $now = time(); printf "\rline %d %8.1f avg lines per second %8.1f lines per s +econd", $linecount, $linecount/($now - $starttime), ($linecount - $la +stlinecount) / ($now - $lasttime); $lasttime = time(); $lastlinecount = $linecount; sleep(.5); } while ($running); }; $starttime = time(); our $thr1 = threads->new(\&progress); while (1) { $linecount++; last if $linecount > 9999; sleep(0.001); }; print "\n"; $running = 0; $thr1->join();
-- gam3
A picture is worth a thousand words, but takes 200K.