当前位置: 首页>>代码示例>>Python>>正文


Python Mininet.runCpuLimitTest方法代码示例

本文整理汇总了Python中mininet.net.Mininet.runCpuLimitTest方法的典型用法代码示例。如果您正苦于以下问题:Python Mininet.runCpuLimitTest方法的具体用法?Python Mininet.runCpuLimitTest怎么用?Python Mininet.runCpuLimitTest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mininet.net.Mininet的用法示例。


在下文中一共展示了Mininet.runCpuLimitTest方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: limit

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import runCpuLimitTest [as 别名]
def limit( bw=10, cpu=.1 ):
    """Example/test of link and CPU bandwidth limits
       bw: interface bandwidth limit in Mbps
       cpu: cpu limit as fraction of overall CPU time"""
    intf = custom( TCIntf, bw=bw )
    myTopo = TreeTopo( depth=1, fanout=2 )
    for sched in 'rt', 'cfs':
        print '*** Testing with', sched, 'bandwidth limiting'
        host = custom( CPULimitedHost, sched=sched, cpu=cpu )
        net = Mininet( topo=myTopo, intf=intf, host=host )
        net.start()
        testLinkLimit( net, bw=bw )
        net.runCpuLimitTest( cpu=cpu )
        net.stop()
开发者ID:09beeihaq,项目名称:Coursera-SDN-Assignments,代码行数:16,代码来源:limit.py

示例2: testCPULimits

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import runCpuLimitTest [as 别名]
    def testCPULimits( self ):
        "Verify topology creation with CPU limits set for both schedulers."
        CPU_FRACTION = 0.1
        CPU_TOLERANCE = 0.8  # CPU fraction below which test should fail
        hopts = { 'cpu': CPU_FRACTION }
        #self.runOptionsTopoTest( N, hopts=hopts )

        mn = Mininet( SingleSwitchOptionsTopo( n=N, hopts=hopts ),
                      host=CPULimitedHost, switch=self.switchClass,
                      waitConnected=True )
        mn.start()
        results = mn.runCpuLimitTest( cpu=CPU_FRACTION )
        mn.stop()
        hostUsage = '\n'.join( 'h%s: %s' %
                               ( n + 1,
                                 results[ (n - 1) * 5 : (n * 5) - 1 ] )
                               for n in range( N ) )
        hoptsStr = ', '.join( '%s: %s' % ( opt, value )
                              for opt, value in hopts.items() )
        msg = ( '\nTesting cpu limited to %d%% of cpu per host\n'
                'cpu usage percent per host:\n%s\n'
                'Topo = SingleSwitchTopo, %s hosts\n'
                'hopts = %s\n'
                'host = CPULimitedHost\n'
                'Switch = %s\n'
                % ( CPU_FRACTION * 100, hostUsage, N, hoptsStr,
                    self.switchClass ) )
        for pct in results:
            #divide cpu by 100 to convert from percentage to fraction
            self.assertWithinTolerance( pct/100, CPU_FRACTION,
                                        CPU_TOLERANCE, msg )
开发者ID:1514louluo,项目名称:mininet,代码行数:33,代码来源:test_hifi.py

示例3: limit

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import runCpuLimitTest [as 别名]
def limit( bw=10, cpu=.1 ):
    """Example/test of link and CPU bandwidth limits
       bw: interface bandwidth limit in Mbps
       cpu: cpu limit as fraction of overall CPU time"""
    intf = custom( TCIntf, bw=bw )
    myTopo = TreeTopo( depth=1, fanout=2 )
    for sched in 'rt', 'cfs':
        info( '*** Testing with', sched, 'bandwidth limiting\n' )
        if sched == 'rt':
            release = quietRun( 'uname -r' ).strip('\r\n')
            output = quietRun( 'grep CONFIG_RT_GROUP_SCHED /boot/config-%s' % release )
            if output == '# CONFIG_RT_GROUP_SCHED is not set\n':
                info( '*** RT Scheduler is not enabled in your kernel. Skipping this test\n' )
                continue
        host = custom( CPULimitedHost, sched=sched, cpu=cpu )
        net = Mininet( topo=myTopo, intf=intf, host=host )
        net.start()
        testLinkLimit( net, bw=bw )
        net.runCpuLimitTest( cpu=cpu )
        net.stop()
开发者ID:Azmonkh,项目名称:mininet,代码行数:22,代码来源:limit.py

示例4: testCPULimits

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import runCpuLimitTest [as 别名]
    def testCPULimits(self):
        "Verify topology creation with CPU limits set for both schedulers."
        CPU_FRACTION = 0.1
        CPU_TOLERANCE = 0.8  # CPU fraction below which test should fail
        hopts = {"cpu": CPU_FRACTION}
        # self.runOptionsTopoTest( N, hopts=hopts )

        mn = Mininet(SingleSwitchOptionsTopo(n=N, hopts=hopts), host=CPULimitedHost)
        mn.start()
        results = mn.runCpuLimitTest(cpu=CPU_FRACTION)
        mn.stop()
        for cpu in results:
            self.assertWithinTolerance(cpu, CPU_FRACTION, CPU_TOLERANCE)
开发者ID:RimHaw,项目名称:mn-ccnx,代码行数:15,代码来源:test_hifi.py

示例5: testCPULimits

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import runCpuLimitTest [as 别名]
    def testCPULimits( self ):
        "Verify topology creation with CPU limits set for both schedulers."
        CPU_FRACTION = 0.1
        CPU_TOLERANCE = 0.8  # CPU fraction below which test should fail
        hopts = { 'cpu': CPU_FRACTION }
        #self.runOptionsTopoTest( N, hopts=hopts )

        mn = Mininet( SingleSwitchOptionsTopo( n=N, hopts=hopts ),
                      host=CPULimitedHost, switch=self.switchClass )
        mn.start()
        results = mn.runCpuLimitTest( cpu=CPU_FRACTION )
        mn.stop()
        for pct in results:
            #divide cpu by 100 to convert from percentage to fraction
            self.assertWithinTolerance( pct/100, CPU_FRACTION, CPU_TOLERANCE )
开发者ID:GregsHub,项目名称:mininet,代码行数:17,代码来源:test_hifi.py


注:本文中的mininet.net.Mininet.runCpuLimitTest方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。