Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Demand Response User
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sepia-pub
Open Science
Demand Response User
Commits
f0f1f9db
Commit
f0f1f9db
authored
3 years ago
by
Maël Madon
Browse files
Options
Downloads
Patches
Plain Diff
campagne d'expe à tester avec multithread python
parent
1810bd29
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
campaign1.py
+29
-10
29 additions, 10 deletions
campaign1.py
instance1.py
+1
-1
1 addition, 1 deletion
instance1.py
with
30 additions
and
11 deletions
campaign1.py
+
29
−
10
View file @
f0f1f9db
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
This diff is collapsed.
Click to expand it.
instance1.py
+
1
−
1
View file @
f0f1f9db
...
@@ -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
(
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment