]> git.donarmstrong.com Git - biopieces.git/commitdiff
optimized track_ruler in BGB
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Mon, 26 Apr 2010 11:37:59 +0000 (11:37 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Mon, 26 Apr 2010 11:37:59 +0000 (11:37 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@949 74ccb610-7750-0410-82ae-013aeee3265d

code_perl/Maasha/BGB/Track.pm
www/index.cgi

index e4f35b756466eb778d116a4fbd95536f83d51975..15e2ba554d73f29d76abd59e2d4aa6f2e8f732e9 100644 (file)
@@ -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";
index c068200ad8c9628773c0fc73a4f3b2d39f21c5e8..64314fa6520ff70122f3b54af9e6c473c8ee0665 100755 (executable)
@@ -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";