|
@@ -11,7 +11,7 @@ from synergine2.simulation import Simulation
|
11
|
11
|
from synergine2.simulation import SubjectBehaviour
|
12
|
12
|
from synergine2.simulation import SubjectMechanism
|
13
|
13
|
from synergine2.simulation import Event
|
14
|
|
-from synergine2.utils import ChunkManager
|
|
14
|
+from synergine2.utils import ChunkManager, time_it
|
15
|
15
|
|
16
|
16
|
|
17
|
17
|
class CycleManager(BaseObject):
|
|
@@ -24,7 +24,8 @@ class CycleManager(BaseObject):
|
24
|
24
|
):
|
25
|
25
|
if process_manager is None:
|
26
|
26
|
process_manager = ProcessManager(
|
27
|
|
- process_count=config.get('use_x_cores', multiprocessing.cpu_count()),
|
|
27
|
+ # TODO: Changer de config de merde (core.use_x_cores)
|
|
28
|
+ process_count=config.get('core', {}).get('use_x_cores', multiprocessing.cpu_count()),
|
28
|
29
|
chunk_manager=ChunkManager(multiprocessing.cpu_count()),
|
29
|
30
|
)
|
30
|
31
|
|
|
@@ -47,8 +48,13 @@ class CycleManager(BaseObject):
|
47
|
48
|
events = []
|
48
|
49
|
# TODO: gestion des behaviours non parallelisables
|
49
|
50
|
# TODO: Proposer des ordres d'execution
|
50
|
|
- events.extend(self._get_subjects_events())
|
51
|
|
- events.extend(self._get_simulation_events())
|
|
51
|
+ with time_it() as elapsed_time:
|
|
52
|
+ events.extend(self._get_subjects_events())
|
|
53
|
+ print('Cycle subjects events duration: {}s'.format(elapsed_time.get_final_time()))
|
|
54
|
+
|
|
55
|
+ with time_it() as elapsed_time:
|
|
56
|
+ events.extend(self._get_simulation_events())
|
|
57
|
+ print('Cycle simulation events duration: {}s'.format(elapsed_time.get_final_time()))
|
52
|
58
|
|
53
|
59
|
self.logger.info('Cycle {} generate {} events'.format(
|
54
|
60
|
str(self.current_cycle),
|
|
@@ -221,12 +227,14 @@ class CycleManager(BaseObject):
|
221
|
227
|
behaviours_data = {}
|
222
|
228
|
|
223
|
229
|
for mechanism in mechanisms:
|
224
|
|
- mechanism_data = mechanism.run()
|
|
230
|
+ with time_it() as elapsed_time:
|
|
231
|
+ mechanism_data = mechanism.run()
|
225
|
232
|
if self.logger.is_debug:
|
226
|
|
- self.logger.info('Subject {}: {} mechanisms produce data: {}'.format(
|
|
233
|
+ self.logger.debug('Subject {}: {} mechanisms produce data: {} in {}s'.format(
|
227
|
234
|
str(subject.id),
|
228
|
235
|
type(mechanism).__name__,
|
229
|
236
|
str(mechanism_data),
|
|
237
|
+ elapsed_time.get_final_time(),
|
230
|
238
|
))
|
231
|
239
|
|
232
|
240
|
mechanisms_data[type(mechanism)] = mechanism_data
|
|
@@ -254,13 +262,15 @@ class CycleManager(BaseObject):
|
254
|
262
|
))
|
255
|
263
|
|
256
|
264
|
# We identify behaviour data with it's class to be able to intersect it after subprocess data collect
|
257
|
|
- behaviour_data = behaviour.run(mechanisms_data) # TODO: Behaviours dependencies
|
|
265
|
+ with time_it() as elapsed_time:
|
|
266
|
+ behaviour_data = behaviour.run(mechanisms_data) # TODO: Behaviours dependencies
|
258
|
267
|
|
259
|
268
|
if self.logger.is_debug:
|
260
|
|
- self.logger.debug('Subject {}: behaviour {} produce data: {}'.format(
|
|
269
|
+ self.logger.debug('Subject {}: behaviour {} produce data: {} in {}s'.format(
|
261
|
270
|
str(type(behaviour)),
|
262
|
271
|
str(subject.id),
|
263
|
272
|
str(behaviour_data),
|
|
273
|
+ elapsed_time.get_final_time(),
|
264
|
274
|
))
|
265
|
275
|
|
266
|
276
|
if behaviour_data:
|