aschult5 / actiontime

A Golang library for tracking action time averages
MIT License
0 stars 1 forks source link

GetStats should be O(1) #21

Closed aschult5 closed 4 years ago

aschult5 commented 4 years ago

Currently, each time GetStats is called the map is iterated over one by one into the list that gets returned. Instead, the data should be stored in a list and the map should hold pointers to each element to maintain O(1) updates of averages. Also, assume that the order of returned actions doesn't matter.

aschult5 commented 4 years ago

This will need to be fixed for concurrent functionality to be any decent

aschult5 commented 4 years ago

Finally getting around to this. Thinking about it more, GetStats can't be O(1) because we will have to make a copy of the data...which is of course O(n). I'll look into reducing the number of copies made (#37), but this isn't as high priority as it was.