예제 #1
0
    def testHyperThread(self):
        prof = SystemProfiler()

        prof.physicalCpus = 8
        prof.logicalCpus = 16

        # hyperthreading enabled but not max procs
        prof.hyperthread_factor = 2
        _, opts = prof.getSubprocessOpts([], cpus=range(3))

        env = opts['env']
        self.assertEqual(env['PLOW_CORES'], '3')
        if IS_LINUX:
            self.assertEqual(env['PLOW_THREADS'], '6',
                             'on Linux, HT should be enabled here')
        else:
            self.assertEqual(env['PLOW_THREADS'], '3',
                             'on non-Linux, HT should be disabled here')

        # pretend we want to run with 2 cores w/o HT
        prof.hyperthread_factor = 1
        _, opts = prof.getSubprocessOpts([], cpus=range(2))

        env = opts['env']
        self.assertEqual(env['PLOW_CORES'], '2')
        self.assertEqual(env['PLOW_THREADS'], '2')

        # hyperthreading enabled and max procs
        prof.hyperthread_factor = 2
        _, opts = prof.getSubprocessOpts([], cpus=range(prof.physicalCpus))

        env = opts['env']
        self.assertEqual(env['PLOW_CORES'], '8')
        self.assertEqual(env['PLOW_THREADS'], '16')
예제 #2
0
파일: test_profile.py 프로젝트: Br3nda/plow
    def testHyperThread(self):
        prof = SystemProfiler()

        prof.physicalCpus = 8
        prof.logicalCpus = 16

        # hyperthreading enabled but not max procs
        prof.hyperthread_factor = 2
        _, opts = prof.getSubprocessOpts([], cpus=range(3))

        env = opts['env']
        self.assertEqual(env['PLOW_CORES'], '3')
        if IS_LINUX:
            self.assertEqual(env['PLOW_THREADS'], '6', 
                'on Linux, HT should be enabled here')
        else:
            self.assertEqual(env['PLOW_THREADS'], '3', 
                'on non-Linux, HT should be disabled here')

        # pretend we want to run with 2 cores w/o HT
        prof.hyperthread_factor = 1
        _, opts = prof.getSubprocessOpts([], cpus=range(2))

        env = opts['env']
        self.assertEqual(env['PLOW_CORES'], '2')
        self.assertEqual(env['PLOW_THREADS'], '2')

        # hyperthreading enabled and max procs
        prof.hyperthread_factor = 2
        _, opts = prof.getSubprocessOpts([], cpus=range(prof.physicalCpus))

        env = opts['env']
        self.assertEqual(env['PLOW_CORES'], '8')
        self.assertEqual(env['PLOW_THREADS'], '16')
예제 #3
0
파일: test_profile.py 프로젝트: Br3nda/plow
    def testSubprocessOpts(self):
        prof = SystemProfiler()

        cmd, opts = prof.getSubprocessOpts('some command')

        self.assertEqual(cmd, ['some', 'command'], 
            "String command should have been split into a list")

        self.assertTrue(isinstance(opts['env'], dict))

        for k, v in opts['env'].iteritems():
            self.assertTrue(isinstance(v, str), 
                "ENV key '%s' has a value %s of type %s instead of str()" % (k, v, type(v)))
예제 #4
0
    def testSubprocessOpts(self):
        prof = SystemProfiler()

        cmd, opts = prof.getSubprocessOpts('some command')

        self.assertEqual(cmd, ['some', 'command'],
                         "String command should have been split into a list")

        self.assertTrue(isinstance(opts['env'], dict))

        for k, v in opts['env'].iteritems():
            self.assertTrue(
                isinstance(v, str),
                "ENV key '%s' has a value %s of type %s instead of str()" %
                (k, v, type(v)))
예제 #5
0
    def testProfile(self):
        prof = SystemProfiler()

        self.assertTrue(
            all(i >= 0 for i in prof.load),
            "System load should not have any negative values: %s" %
            str(prof.load))