Skip to content

small python lib to count events in a short period of time

License

Notifications You must be signed in to change notification settings

Katy-katy/event_counter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

event_counter: Python3 module for counting the events in a short time interval

Counter can be used for keeping truck of events for the last 5 minutes (300 seconds) and counting the number of events in given time interval (the interval must be from the last 5 munutes). We assume that we will have no more than 1 mullion events per second.

Installation

The package we can install using pip from the project root:

pip install ./dist/event_counter-0.0.1.tar.gz

Example

Import Counter:

from  event_counter.counter import Counter

Create a Counter:

my_counter = Counter()

Every time when an event has happened:

my_counter.add_event()

When we need to find the number of events in a time interval:

events_number = my_counter.count_events("21.05.2018 20:44:02", "21.05.2018 20:47:02")

Count events that heppened in the last 5 munutes (current second will not be included):

events_number_5_min = my_counter.count_events()

About

small python lib to count events in a short period of time

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages