Hi,

bat is rather slow for me with loading very large backups into the restore window. I therefore did some profiling of it using KCacheGrind (which uses callgrind, part of valgrind).

It showed that the construction and use of QRegExp in each call to restoreTree::parseDirectory() is highly expensive. I have therefore replaced the use of QRegExp with an (functionally identical, hopefully) QString alternative. The performance impact of cleaning up the directory tree is now negligible. Loading the same job into bat now takes 329 seconds rather than 466 seconds for me.

The uses of QRegExp::lastIndexIn() in other parts of restoretree.cpp are also quite expensive (but no where near as bad) and I think could be replaced with a similar QString alternative. I will have a go, and continue profiling bat...
Index: restore/restoretree.cpp
===================================================================
--- restore/restoretree.cpp	(revision 5623)
+++ restore/restoretree.cpp	(working copy)
@@ -329,10 +329,12 @@
    if (m_debugCnt > 2)
       m_debugTrap = false;
    /* Clean up the directory string remove some funny char after last '/' */
-   QRegExp rgx("[^/]$");
-   int lastslash = rgx.indexIn(dir_in);
-   if (lastslash != -1)
-      dir_in.replace(lastslash, dir_in.length()-lastslash, "");
+   /* if the final character isn't a /, truncate everything after it */
+   if (dir_in.right(1) != "/")
+   {
+      dir_in.truncate(dir_in.lastIndexOf("/") + 1);
+   }
+
    if ((mainWin->m_miscDebug) && (m_debugTrap))
       Pmsg1(000, "parsing %s\n", dir_in.toUtf8().data());
 
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Bacula-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bacula-devel

Reply via email to