From 56d94be9dcc45227240ee06eb6c787f276d43c57 Mon Sep 17 00:00:00 2001 From: Don Armstrong Date: Mon, 19 Mar 2012 12:48:52 -0700 Subject: [PATCH] add Term::ProgressBar entry --- posts/using_term_progressbar.mdwn | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 posts/using_term_progressbar.mdwn diff --git a/posts/using_term_progressbar.mdwn b/posts/using_term_progressbar.mdwn new file mode 100644 index 0000000..cd7a8b8 --- /dev/null +++ b/posts/using_term_progressbar.mdwn @@ -0,0 +1,31 @@ +[[!meta title="Using Term::Progressbar"]] + +I've been working for a while on analyzing a fairly large dataset for +my Lupus genetics project. One of the major annoyances with analyzing +large datasets is not knowing when a particular part of the analysis +is going to finish, and whether I should go back and rewrite part of +the code to be faster, or just wait for it to finish. In R, I've been +using txtProgressBar to handle this, but I hadn't bothered to find a +similar module for perl until now. + +Luckily, +[Term::ProgressBar](http://search.cpan.org/dist/Term-ProgressBar/) +exists, and is pretty easy to use: + + my $pos = $sfh->tell(); + $sfh->seek(0,SEEK_END); + my $p = Term::ProgressBar->new({count => $sfh->tell, + remove => 1, + ETA => 'linear'}); + $sfh->seek($pos,SEEK_SET); + while (<$sfh>) { + ...; # yada yada yada + $p->update($sfh->tell()); + } + +producing useful output, which told me that my SQLite database +creation routine would take about 2 days to finish instead of the 7 +years that the slightly less optimal version wanted. + + +[[!tag tech perl]] -- 2.39.2