Skip to content
Snippets Groups Projects
Commit f0f1f9db authored by Maël Madon's avatar Maël Madon
Browse files

campagne d'expe à tester avec multithread python

parent 1810bd29
No related branches found
No related tags found
No related merge requests found
from random import * import random
from time import * from time import *
import multiprocessing import concurrent.futures
from instance1 import start_instance from instance1 import start_instance
# Prepare the start date samples # Prepare the start date samples
begin_trace = 1356994806 # according to original SWF header begin_trace = 1356994806 # according to original SWF header
jun1_unix_time, nov30_unix_time = mktime(strptime('Sun Jun 1 00:00:00 2014')), mktime(strptime('Sun Nov 30 23:59:59 2014')) jun1_unix_time, nov30_unix_time = mktime(strptime(
jun1, nov30 = (int) (jun1_unix_time - begin_trace), (int) (nov30_unix_time - begin_trace) 'Sun Jun 1 00:00:00 2014')), mktime(strptime('Sun Nov 30 23:59:59 2014'))
jun1, nov30 = (int)(jun1_unix_time -
begin_trace), (int)(nov30_unix_time - begin_trace)
random.seed(1997) random.seed(1997)
instances = [] nb_expe = 2
for i in range(2):
start_date = randint(jun1, nov30 - 72 * 3600)
instane = multiprocessing.Process(target=start_instance, args=) def print_two(a, b):
print(a, b)
sleep(3)
print("hello")
return 0
start_dates = [random.randint(jun1, nov30 - 72 * 3600)
for _ in range(nb_expe)]
with concurrent.futures.ProcessPoolExecutor() as executor:
instances = [executor.submit(start_instance, i, start_dates[i])
for i in range(nb_expe)]
for instance in concurrent.futures.as_completed(instances):
print(instance.result())
# For every start date # For every start date
# Call the one_instance file with this date # Call the one_instance file with this date
\ No newline at end of file
...@@ -99,7 +99,7 @@ def start_instance(expe_num, start_date): ...@@ -99,7 +99,7 @@ def start_instance(expe_num, start_date):
###### Output data treatment ###### ###### Output data treatment ######
# Produce the utilisation viz? # Produce the utilisation viz?
return 0
def main(): def main():
parser = argparse.ArgumentParser( parser = argparse.ArgumentParser(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment