Tags:
create new tag
, view all tags
I can't explain why, but getTopicNames is an absolute dog. Big page:

 Total Elapsed Time = 12.13708 Seconds
  User+System Time = 5.237084 Seconds
Exclusive Times
%Time ExclSec CumulS #Calls sec/call Csec/c  Name
 23.4   1.230  1.230      1   1.2300 1.2300  TWiki::Store::getTopicNames
 15.3   0.805  0.805   5970   0.0001 0.0001  FormQueryPlugin::ColourMap::map
 12.8   0.674  1.325      3   0.2247 0.4416  TWiki::Render::getRenderedVersion
 6.01   0.315  0.331     14   0.0225 0.0236  TWiki::Prefs::PrefsCache::replaceP
                                             referencesTags
 5.17   0.271  0.271  23557   0.0000 0.0000  TWiki::Contrib::Map::get
 4.66   0.244  0.251   1221   0.0002 0.0002  TWiki::Store::topicExists
 3.82   0.200  1.306   5970   0.0000 0.0002  FormQueryPlugin::TableFormat::_exp
                                             andField
 3.44   0.180  0.180      1   0.1800 0.1800  Storable::pretrieve
 3.44   0.180  0.180      3   0.0600 0.0600  TWiki::Plugins::InterwikiPlugin::s
                                             tartRenderingHandler
 3.44   0.180  5.082      1   0.1799 5.0824  TWiki::UI::View::view
 3.06   0.160  0.199     27   0.0059 0.0074  TWiki::BEGIN
 2.10   0.110  0.156     14   0.0079 0.0111  TWiki::handleInternalTags
 1.53   0.080  0.099     23   0.0035 0.0043  TWiki::Func::BEGIN
 0.95   0.050  0.249      3   0.0166 0.0831  TWiki::UI::View::BEGIN
 0.86   0.045  3.275   1392   0.0000 0.0024  TWiki::Plugins::applyHandlers
That's ridiculous! The problem appears to be the "-d" check. Removing that check removes it from the profile altogether.
    my @tmpList = readdir( DIR );
    closedir( DIR );

    # this is not magic, it just looks like it.
    my @topicList = sort
        grep { s#^.+/([^/]+)\.txt$#$1# }
        #grep { ! -d }
        map  { "$TWiki::dataDir/$web/$_" }
        grep { ! /^\.\.?$/ } @tmpList;

Of course the quicker among you will have noticed this can then be recoded to:
    my @topicList = sort grep { s/\.txt$// } readdir( DIR );
    closedir( DIR );
Which no longer claims to be magic, but really is.

Of course this'll fail if someone is stupid enough to create a directory called ImATotalIdiot.txt then this will fail, but hey, it's worth the risk.

getSubWebNames should get the same treatment. And any other uses of -d should be examined carefully.

-- CrawfordCurrie - 14 Sep 2004

Good point. This is now in SVN.

Index: Store.pm
===================================================================
--- Store.pm    (revision 1750)
+++ Store.pm    (working copy)
@@ -1647,16 +1647,8 @@

     # get list of all topics by scanning $dataDir
     opendir DIR, "$TWiki::dataDir/$web" ;
-    my @tmpList = readdir( DIR );
+    my @topicList = sort grep { s/\.txt$// } readdir( DIR );
     closedir( DIR );
-
-    # this is not magic, it just looks like it.
-    my @topicList = sort
-        grep { s#^.+/([^/]+)\.txt$#$1# }
-        grep { ! -d }
-        map  { "$TWiki::dataDir/$web/$_" }
-        grep { ! /^\.\.?$/ } @tmpList;
-
     return @topicList ;
 }
 #/AS

A quick scan reveils two more -d, one in Store.pm, one in Search.pm. Both are getting a list of directories, where above trick cannot be applied.

-- PeterThoeny - 16 Sep 2004

Edit | Attach | Watch | Print version | History: r6 < r5 < r4 < r3 < r2 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r6 - 2005-02-13 - SamHasler
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.