elf_firein has asked for the wisdom of the Perl Monks concerning the following question:
I have one subroutine which is running for ithread. The job of this subroutine is to refresh terminal object created through Term::Screen. When all rows of the screen is filled up & new line is added the screen is getting drifted & the topmost line is displayed on screen multiple times while scroll up the screen. I am able to solve this problem following way: 1. Maximum number of number of rows the screen supported 2. Remembering the line which is printed in top-most line of the screen while crossing max row. For that one complete hash need to be remembered for at least for 80 consecutive runs. Sample code is here:
If I use closure instead of global variable like %hash, will it reduce the performance? Or it will increase the performance as it is associated with ithread? One more thing, Is my approach is right in order to stop the duplicate print on screen while scrolling? Few more hashes may require to remember data while refreshing the screen in future.Hash outside the sub routine: %hash = (); // for storing drift line %printable_data = (); // some data are there $terminal = new Term::Screen; $screen_height = $terminal->row; The thread subroutine: sub refresher { $terminal->at(0,0); $terminal->clreos(); foreach (keys %printable_data) { $term->puts($_); . . . if ( $curser_position >= $screen_height ) { $hash{$key} = $_; } } }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Will closure increase performance thread processing subroutine?
by BrowserUk (Patriarch) on Jun 25, 2011 at 17:11 UTC | |
Re: Will closure increase performance while used in suroutine of thread?
by ikegami (Patriarch) on Jun 25, 2011 at 17:11 UTC |
Back to
Seekers of Perl Wisdom