From: martinahansen Date: Mon, 26 Apr 2010 11:37:59 +0000 (+0000) Subject: optimized track_ruler in BGB X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=1860362cfa1d3ee0f395593087dfc3aff040a28b;p=biopieces.git optimized track_ruler in BGB git-svn-id: http://biopieces.googlecode.com/svn/trunk@949 74ccb610-7750-0410-82ae-013aeee3265d --- diff --git a/code_perl/Maasha/BGB/Track.pm b/code_perl/Maasha/BGB/Track.pm index e4f35b7..15e2ba5 100644 --- a/code_perl/Maasha/BGB/Track.pm +++ b/code_perl/Maasha/BGB/Track.pm @@ -31,6 +31,7 @@ package Maasha::BGB::Track; use warnings; use strict; use Data::Dumper; +use Time::HiRes; use Maasha::Common; use Maasha::Calc; use Maasha::Filesys; @@ -115,25 +116,28 @@ sub track_ruler $step *= 5; } - for ( $i = $beg; $i < $end; $i++ ) + for ( $i = $beg; $i < $end; $i++ ) { # TODO: this loop is slow! + last if ( ( $i % $step ) == 0 ); + } + + while ( $i < $end ) { - if ( ( $i % $step ) == 0 ) - { - $txt = "|" . Maasha::Calc::commify( $i ); - $x = sprintf( "%.0f", ( ( $i - $beg ) * $factor ) + 2 ); + $txt = "|" . Maasha::Calc::commify( $i ); + $x = sprintf( "%.0f", ( ( $i - $beg ) * $factor ) + 2 ); - if ( $x > 0 and $x + ( $cookie->{ 'RULER_FONT_SIZE' } * length $txt ) < $cookie->{ 'IMG_WIDTH' } ) - { - push @ruler, { - type => 'text', - txt => $txt, - font_size => $cookie->{ 'RULER_FONT_SIZE' }, - color => $cookie->{ 'RULER_COLOR' }, - x1 => $x, - y1 => $cookie->{ 'TRACK_OFFSET' }, - }; - } + if ( $x > 0 and $x + ( $cookie->{ 'RULER_FONT_SIZE' } * length $txt ) < $cookie->{ 'IMG_WIDTH' } ) + { + push @ruler, { + type => 'text', + txt => $txt, + font_size => $cookie->{ 'RULER_FONT_SIZE' }, + color => $cookie->{ 'RULER_COLOR' }, + x1 => $x, + y1 => $cookie->{ 'TRACK_OFFSET' }, + }; } + + $i += $step; } $cookie->{ 'TRACK_OFFSET' } += $cookie->{ 'TRACK_SPACE' }; @@ -1179,3 +1183,7 @@ sub track_feature return wantarray ? @{ $features } : $features; } + + +my $t0 = Time::HiRes::gettimeofday(); +my $t1 = Time::HiRes::gettimeofday(); print STDERR "Time: " . ( $t1 - $t0 ) . "\n"; diff --git a/www/index.cgi b/www/index.cgi index c068200..64314fa 100755 --- a/www/index.cgi +++ b/www/index.cgi @@ -29,6 +29,7 @@ use CGI; use URI::Escape; use Data::Dumper; use Digest::MD5; +use Time::HiRes; use Maasha::Common; use Maasha::Filesys; use Maasha::Calc; @@ -1571,3 +1572,7 @@ sub section_dna __END__ + + + # my $t0 = Time::HiRes::gettimeofday(); + # my $t1 = Time::HiRes::gettimeofday(); print STDERR "Time: " . ( $t1 - $t0 ) . "\n";