https://github.com/pokle/coding-exercise-traffic-counter
Stats about cars that pass a traffic counter ππ
https://github.com/pokle/coding-exercise-traffic-counter
coding-exercise
Last synced: 2 months ago
JSON representation
Stats about cars that pass a traffic counter ππ
- Host: GitHub
- URL: https://github.com/pokle/coding-exercise-traffic-counter
- Owner: pokle
- Created: 2018-05-26T05:49:06.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-05-28T10:33:49.000Z (almost 8 years ago)
- Last Synced: 2024-12-29T23:24:30.316Z (about 1 year ago)
- Topics: coding-exercise
- Language: Python
- Homepage:
- Size: 32.2 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Traffic counter
[](https://travis-ci.org/pokle/coding-exercise-traffic-counter)
- Single pass line by line streaming (tested on a large file)
- Constant memory usage ~12mb ram
- Can process about 130,000 lines/second on my 2013 macbook pro.
- Current bottleneck is CPU.
## Running it
Ensure you have python 3 installed (brew install python3)
Verify everything's in order by running the tests: `make test`
Then you're good to go:
```
$ python3 traffic_report.py data.file
## Count of cars grouped by date
2016-12-01 179
2016-12-05 81
2016-12-08 134
2016-12-09 4
## Total cars = 398
## Top 3 half hours
2016-12-01T07:30:00 46
2016-12-01T08:00:00 42
2016-12-08T18:00:00 33
## 1.5 hour period with βleastβ cars = 20 cars [2016-12-01T15:00:00 .. 2016-12-01T23:30:00]
```