Пример #1
0
    def testAmdahlModelLinear(self):
        points = [SimpleDataPoint(cpuCount=1, cpu=1, time=1000, probSize=35, totalMemory=100), 
                  SimpleDataPoint(cpuCount=2, cpu=1, time=600, probSize=35, totalMemory=100), 
                  SimpleDataPoint(cpuCount=2, cpu=1, time=1200, probSize=70, totalMemory=100)]
        
        model = AmdahlsCompModel(dataPoints=points, scaleFunction='linear')
        
        self.assertEquals(1000, model.modelFunc(probSize=35, cpu=1, count=1))
        self.assertEquals(600, model.modelFunc(probSize=35, cpu=1, count=2))
        self.assertAlmostEquals(400, model.modelFunc(probSize=35, cpu=1, count=4))
        self.assertAlmostEquals(300, model.modelFunc(probSize=35, cpu=1, count=8))
        
        self.assertAlmostEquals(1200, model.modelFunc(probSize=70, cpu=1, count=2))
        self.assertAlmostEquals(2400, model.modelFunc(probSize=140, cpu=1, count=2))
        return 
        plots= []
        plots.append(plot([35, 35, 70],[1000, 600, 1200],'ro')) 
        labels = ['real']
    
        probSize = linspace(0,200,5)
    
        for count in range(1,5):
            plots.append(plot(probSize, model.modelFunc(probSize, None, count)))
            labels.append("%d" % count)
    
            legend([p[0] for p in plots], labels)

        show()
Пример #2
0
 def testAmdahlModelLinearVariousCpu2(self):
     points = [SimpleDataPoint(cpuCount=1, cpu=1, time=1000, probSize=35, totalMemory=100), 
               SimpleDataPoint(cpuCount=2, cpu=2, time=300, probSize=35, totalMemory=100), 
               SimpleDataPoint(cpuCount=2, cpu=1, time=1200, probSize=70, totalMemory=100)]
     
     model = AmdahlsCompModel(dataPoints=points, scaleFunction='linear')
     
     self.assertEquals(1000, model.modelFunc(probSize=35, cpu=1, count=1))
     self.assertEquals(600, model.modelFunc(probSize=35, cpu=1, count=2))
     self.assertAlmostEquals(400, model.modelFunc(probSize=35, cpu=1, count=4))
     self.assertAlmostEquals(300, model.modelFunc(probSize=35, cpu=1, count=8))
     
     self.assertAlmostEquals(1200, model.modelFunc(probSize=70, cpu=1, count=2))
     self.assertAlmostEquals(1200, model.modelFunc(probSize=140, cpu=2, count=2))