in reply to marking time during function call

If the load is multiple statements, you can easily put in a ticker, either by number of steps, or by time lapsed.

In some cases you may be able to interrupt whatever is happening with an alarm to print a ticker, set another alarm, and the resume the activity. This is highly dependent on what is actually running. With safe signals, some actions are not nicely interruptible.

Show some toy code, and someone will be along to tweak it for you.

-QM
--
Quantum Mechanics: The dreams stuff is made of

Replies are listed 'Best First'.
Re^2: marking time during function call
by lycanhunter (Initiate) on Jun 17, 2015 at 17:38 UTC

    the script now works with a heartbeat. Thank You again

    my @voblist = `cat /home/vobadmin/scripts/voblist.txt`; foreach my $i (@voblist) { chomp($i); my $vob = "\/vobs\/$i"; chomp($vob); print '[' . timestamp() . '] Start Time'. "\n"; print OUTFILE '[' . timestamp() . '] Start Time'. "\n"; print "VOB is: $vob\n"; chdir $vob; open($FH, "cleartool find . -all -print|") or die "Something went wrong\n"; print STDERR "Loading Array with elements from $vob\n "; while (<$FH>) { push @element, $_; unless ($. % 10) { # every 10 lines print STDERR "."; } } print "\n";

    Now fill the array while it is keeping heartbeat.

Re^2: marking time during function call
by lycanhunter (Initiate) on Jun 17, 2015 at 15:19 UTC

    A simple script would be like

    @march = `cleartool find /vobs/41Rational_Val/. -all -print`; while (<@march>) { ### processing... done } print "\n"; close(@march);

    This using the Smart Comments module. But it waits until the load of the array finishes before displaying the progress.

      I don't have time at the moment to do full justice to this, but an (untested!) snippet might look like this:
      open(my $FH, "cleartool find /vobs/41Rational_Val/. -all -print|") or die "Something went wrong\n"; print STDERR "Reading cleartool command, line "; while (<$FH>) { do_something_here; unless ($. % 200) { # every 200 lines print STDERR "$. "; } }

      However, there is no way to know the percent complete progress of the cleartool command.

      -QM
      --
      Quantum Mechanics: The dreams stuff is made of

        QM A Scholar and a Gentleman Thank You. I was able to modify slightly and now have a basic heartbeat while the array is loaded