A have made a little tool to test the speed of the depsolver in yum

here is a test of timing the depsolve of k3b in a clean root:
sudo ./testyum.py --installroot=/tmp/yum-test k3b

the tool have all the normal command line switch in yum cli.

Tim
#!/usr/bin/python -tt
#
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Library General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

import sys
sys.path.insert(0,'/usr/share/yum-cli')

import yum

from cli import *
from utils import YumUtilBase
from yum.misc import getCacheDir

import time

class YumDepTester(YumUtilBase):
    NAME = 'testyum'
    VERSION = '1.0'
    USAGE = '"usage: testyum package1 [package2] [package..]'
    
    def __init__(self):
        YumUtilBase.__init__(self,
                             YumDepTester.NAME,
                             YumDepTester.VERSION,
                             YumDepTester.USAGE)
        self.logger = logging.getLogger("yum.verbose.cli.yumdeptester")                             
        self.main()

    def main(self):
        parser = self.getOptionParser() 
        opts = self.doUtilConfigSetup()
        # Check if there is anything to do.
        if len(self.cmds) < 1: 
            parser.print_help()
            sys.exit(0)

        # make yumdownloader work as non root user.
        if self.conf.uid != 0:
            cachedir = getCacheDir()
            if cachedir is None:
                self.logger.error("Error: Could not make cachedir, exiting")
                sys.exit(50)
            self.repos.setCacheDir(cachedir)
        
        # Setup yum (Ts, RPM db, Repo & Sack)
        self.doUtilYumSetup()
        # Do the real action
        self.doDepTest()

    def doDepTest(self):        
        for p in self.cmds:
            self.logger.info('Adding : %s ' % p)
            self.addPackage(p)
        # buildTransaction
        startTime = time.time()
        print "Starting buildTransaction "
        (res, resmsg) = self.buildTransaction()
        endTime = time.time()
        print "buildTransaction took : %2f " % (endTime - startTime)
        if res != 2:
            print "Unable to build transaction"
            for m in resmsg:
                print m
            sys.exit(1)
        else:
            pass

    def addPackage(self, pkg):
        try:
            mbrs = self.install(pattern = pkg)
            return len(mbrs)
        except yum.Errors.InstallError:
            print >> sys.stderr, "No package matching %s" %(pkg,)
            return 0
    
if __name__ == "__main__":
    util = YumDepTester()

_______________________________________________
Yum-devel mailing list
Yum-devel@linux.duke.edu
https://lists.dulug.duke.edu/mailman/listinfo/yum-devel

Reply via email to