Skip to content

Commit

Permalink
Move function to bottom of file, since it will rarely be touched comp…
Browse files Browse the repository at this point in the history
…ared to the other functions
  • Loading branch information
ccrock4t committed May 2, 2024
1 parent 83e8275 commit 7c7b8c4
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions pynars/NARS/Control/Reasoner.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,21 +120,6 @@ def cycle(self):
return tasks_derived, judgement_revised, goal_revised, answers_question, answers_quest, (
task_operation_return, task_executed)

def do_cycle_metrics(self, start_cycle_time_in_seconds: float):
# record some metrics
total_cycle_duration_in_seconds = time() - start_cycle_time_in_seconds
self.last_cycle_duration = total_cycle_duration_in_seconds # store the cycle duration
# put it in with the others to find the avg duration
self.cycles_durations_window.append(total_cycle_duration_in_seconds)
self.cycles_duration_window_sum += total_cycle_duration_in_seconds

# we only want to keep track of a certain number of cycles, so remove old cycles
if len(self.cycles_durations_window) > Config.Config.cycle_durations_window_length:

self.cycles_duration_window_sum -= self.cycles_durations_window[0]
self.cycles_durations_window.pop(0)

self.avg_cycle_duration = self.cycles_duration_window_sum / len(self.cycles_durations_window) # avg seconds per 1 cycle

def consider(self, tasks_derived: List[Task]):
"""
Expand Down Expand Up @@ -298,3 +283,20 @@ def register_operator(self, name_operator: str, callback: Callable):
Operation.register(op, callback)
return op
return None

def do_cycle_metrics(self, start_cycle_time_in_seconds: float):
# record some metrics
total_cycle_duration_in_seconds = time() - start_cycle_time_in_seconds
self.last_cycle_duration = total_cycle_duration_in_seconds # store the cycle duration
# put it in with the others to find the avg duration
self.cycles_durations_window.append(total_cycle_duration_in_seconds)
self.cycles_duration_window_sum += total_cycle_duration_in_seconds

# we only want to keep track of a certain number of cycles, so remove old cycles
if len(self.cycles_durations_window) > Config.Config.cycle_durations_window_length:

self.cycles_duration_window_sum -= self.cycles_durations_window[0]
self.cycles_durations_window.pop(0)

self.avg_cycle_duration = self.cycles_duration_window_sum / len(self.cycles_durations_window) # avg seconds per 1 cycle

0 comments on commit 7c7b8c4

Please sign in to comment.