Skip to content

Commit

Permalink
store cycle metrics in reasoner; calculate cycles per second
Browse files Browse the repository at this point in the history
  • Loading branch information
ccrock4t committed Jan 18, 2024
1 parent 2276950 commit 624dee0
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion pynars/NARS/Control/Reasoner.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ def __init__(self, n_memory, capacity, config='./config.json', nal_rules={1, 2,

self.u_top_level_attention = 0.5

# metrics
self.cycles_per_second_timer = 0
self.cycles_per_second_counter = 0
self.cycles_per_second = 0
self.last_cycle_time = 0

def reset(self):
self.memory.reset()
self.overall_experience.reset()
Expand Down Expand Up @@ -111,8 +117,18 @@ def cycle(self):


# done with cycle

# record some metrics
total_cycle_time_in_seconds = time.time() - start_cycle_time_in_seconds
print("cycle took: " + str(total_cycle_time_in_seconds))
self.last_cycle_time = total_cycle_time_in_seconds
self.cycles_per_second_timer += total_cycle_time_in_seconds
self.cycles_per_second_counter += 1
if self.cycles_per_second_timer > 1:
# 1 second has passed
self.cycles_per_second = self.cycles_per_second_counter # store the result
self.cycles_per_second_timer = 0 # reset the timer
self.cycles_per_second_counter = 0 # reset the counter


return tasks_derived, judgement_revised, goal_revised, answers_question, answers_quest, (
task_operation_return, task_executed)
Expand Down

0 comments on commit 624dee0

Please sign in to comment.