Ejemplo n.º 1
0
    cpuSequence = [0.1, 0.8, 0.30, 0.70, 0.40, 0.10, 0.20, 0.60, 0.20, 0.70]
    ######################################################
    #             IDENTIFICATION TEST                    #
    ######################################################
    # testing activities
    # this test aims at characterizing the CPU
    testing = 1
    dynamics_plot_online = 0
    if testing == 1:
    
        sleepTimeTest = [ cpu_model(x) for x in cpuSequence]

        data = {"x":[], "y":[]}
        for sleepTime in sleepTimeTest:
            monitor = MonitorThread(0, 0.1)
            monitor.setSleepTimeTarget(sleepTime)
            monitor.start()

            actuator = openLoopActuator(monitor, 10, 0, dynamics_plot_online)
            actuator.setSleepTime(sleepTime)
            actuator.run()
            
            monitor.running = 0
            dynamics =  monitor.getDynamics()
            actuator.close()
            monitor.join()

            data['x'].append(sleepTime)
            data['y'].append(sum(dynamics['cpu']) / float(len(dynamics['cpu'])))

            monitor.running = 0