示例#1
0
    else:
        if options['cpuLoad'] < 0 or options['cpuLoad'] > 1:
            print("CPU target load out of the range [0,1]")
            sys.exit(1)
        if options['duration'] < 0:
            print("Invalid duration")
            sys.exit(1)
        if options['plot'] != 0 and options['plot'] != 1:
            print("plot can be enabled 1 or disabled 0")
            sys.exit(1)
        if options['cpu_core'] >= multiprocessing.cpu_count():
            print("You have only %d cores on your machine" %
                  (multiprocessing.cpu_count()))
            sys.exit(1)

    monitor = MonitorThread(options['cpu_core'], 0.1)
    monitor.start()

    control = ControllerThread(0.1)
    control.start()
    control.setCpuTarget(options['cpuLoad'])

    actuator = closedLoopActuator(control, monitor, options['duration'],
                                  options['cpu_core'], options['cpuLoad'],
                                  options['plot'])
    actuator.run()
    actuator.close()

    monitor.running = 0
    control.running = 0
    monitor.join()
示例#2
0
if __name__ == "__main__":
   
    ######################################################
    #             PID TEST                               # 
    ######################################################
    # testing activities
    # this test aims at characterizing the CPU
    testing = 1
    dynamics_plot_online = 0
    if testing == 1:
        cpuSequence = [0.8, 0.1, 0.30, 0.70, 0.40, 0.10, 0.20, 0.60, 0.20, 0.70]
        #cpuSequence = [0.8, 0.1]
        stepPeriod = 4

        control = ControllerThread(0.1)
        monitor = MonitorThread(0, 0.1)
        actuator = closedLoopActuator(control, monitor, len(cpuSequence) * stepPeriod, 0, 1, dynamics_plot_online)

        monitor.start()
        control.start()
        actuator.run_sequence(cpuSequence)
        
        actuator.close()
        monitor.running = 0
        control.running = 0
        dynamics =  monitor.getDynamics()
       
        monitor.join()
        control.join()
        
        stepPeriod = 4
示例#3
0
    # testing activities
    # this test aims at characterizing the CPU
    testing = 1
    dynamics_plot_online = 0
    if testing == 1:
        sleepTimeSequence = [
            0.001, 0.005, 0.01, 0.02, 0.03, 0.08, 0.1, 0.15, 0.2, 0.3, 0.4, 0.5
        ]
        cpuSequence = [
            0.1, 0.8, 0.30, 0.70, 0.40, 0.10, 0.20, 0.60, 0.20, 0.70
        ]
        #cpuSequence = [ 0.80]
        #sleepTimeSequence = [0.001,  0.02]
        sleepTimeSequence = [cpu_model(x) for x in cpuSequence]
        stepPeriod = 4
        monitor = MonitorThread(0, 0.1)
        actuator = openLoopActuator(monitor,
                                    len(sleepTimeSequence) * stepPeriod, 0,
                                    dynamics_plot_online)
        monitor.start()
        actuator.run_sequence(sleepTimeSequence)

        monitor.running = 0
        dynamics = monitor.getDynamics()
        actuator.close()
        monitor.join()

        with open('feed_forward_data', 'w') as outfile:
            json.dump(dynamics, outfile)
    else:
        with open('feed_forward_data', 'r') as outfile:
        sys.exit(1)
    else:
        if options["cpuLoad"] < 0 or options["cpuLoad"] > 1:
            print "CPU target load out of the range [0,1]"
            sys.exit(1)
        if options["duration"] < 0:
            print "Invalid duration"
            sys.exit(1)
        if options["plot"] != 0 and options["plot"] != 1:
            print "plot can be enabled 1 or disabled 0"
            sys.exit(1)
        if options["cpu_core"] >= multiprocessing.cpu_count():
            print "You have only %d cores on your machine" % (multiprocessing.cpu_count())
            sys.exit(1)

    monitor = MonitorThread(options["cpu_core"], 0.1)
    monitor.start()

    control = ControllerThread(0.1)
    control.start()
    control.setCpuTarget(options["cpuLoad"])

    actuator = closedLoopActuator(
        control, monitor, options["duration"], options["cpu_core"], options["cpuLoad"], options["plot"]
    )
    actuator.run()
    actuator.close()

    monitor.running = 0
    control.running = 0
    monitor.join()
示例#5
0
if __name__ == "__main__":
    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'])))