Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __call__(self):
computation_amount = this_actor.get_host().speed
this_actor.info("Execute {:.0f} flops, should take 1 second.".format(computation_amount))
activity = this_actor.exec_init(computation_amount).start()
this_actor.sleep_for(0.5)
this_actor.info("I changed my mind, cancel!")
activity.cancel()
this_actor.info("Goodbye now!")
def __call__(self):
computation_amount = this_actor.get_host().speed
this_actor.info("Execute {:.0f} flops, should take 1 second.".format(computation_amount))
activity = this_actor.exec_init(computation_amount).start()
while not activity.test():
this_actor.info("Remaining amount of flops: {:.0f} ({:.0f}%)".format(
activity.remaining, 100 * activity.remaining_ratio))
this_actor.sleep_for(0.3)
activity.wait()
this_actor.info("Goodbye now!")
def dream_master():
"""The Dream master"""
this_actor.info("Let's create a lazy guy.") # Create a lazy_guy process
lazy = Actor.create("Lazy", this_actor.get_host(), lazy_guy)
this_actor.info("Let's wait a little bit...")
this_actor.sleep_for(10) # Wait for 10 seconds
this_actor.info("Let's wake the lazy guy up! >:) BOOOOOUUUHHH!!!!")
if lazy.is_suspended():
lazy.resume() # Then wake up the lazy_guy
else:
this_actor.error(
"I was thinking that the lazy guy would be suspended now")
this_actor.sleep_for(5) # Repeat two times:
this_actor.info("Suspend the lazy guy while he's sleeping...")
lazy.suspend() # Suspend the lazy_guy while he's asleep
this_actor.info("Let him finish his siesta.")
this_actor.sleep_for(10) # Wait for 10 seconds
this_actor.info("Wake up, lazy guy!")
lazy.resume() # Then wake up the lazy_guy again
def __call__(self):
workload = 100E6
host = this_actor.get_host()
nb = host.get_pstate_count()
this_actor.info("Count of Processor states={:d}".format(nb))
this_actor.info("Current power peak={:f}".format(host.speed))
# Run a task
this_actor.execute(workload)
task_time = Engine.get_clock()
this_actor.info("Task1 duration: {:.2f}".format(task_time))
# Change power peak
new_pstate = 2
this_actor.info("Changing power peak value to {:f} (at index {:d})".format( host.get_pstate_speed(new_pstate), new_pstate))