-
-
Save rahulrajaram/4f079aa76d2ad0eb16c7e2febbc55fa1 to your computer and use it in GitHub Desktop.
Printing distribution of floats over 1 second intervals
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
This scripts loads a file that contains stringified floats expected | |
to be seconds since epoch listed in a comma-separated fashion as | |
follows: | |
"1638201720.793","1638201720.778","1638201720.770","1638201719.866","1638201710.152","1638201710.140","1638201709.727","1638201707.715","1638201704.069","1638201702.769","1638201702.757","1638201699.529","1638201699.363","1638201699.362","1638201689.308","1638201688.406","1638201686.458","1638201686.097","1638201685.893","1638201685.620","1638201685.350","1638201685.035","1638201684.650","1638201682.229","1638201679.695","1638201678.098","1638201677.825","1638201676.972","1638201676.640","1638201675.442","1638201674.020","1638201672.890","1638201672.862","1638201669.458","1638201669.364","1638201665.908","1638201665.606","1638201665.271","1638201665.138","1638201664.315","1638201664.298","1638201663.204","1638201662.234","1638201661.479","1638201661.368","1638201660.295","1638201660.256","1638201660.108","1638201660.097","1638201660.010","1638201659.797","1638201658.931","1638201658.926","1638201658.925","1638201658.894","1638201657.563","1638201656.421","1638201653.347","1638201652.219","1638201651.557","1638201651.417","1638201651.280","1638201650.007","1638201649.329","1638201649.284","1638201648.912","1638201648.256","1638201648.028","1638201648.016","1638201648.010","1638201648.007","1638201647.939","1638201647.014","1638201646.966","1638201645.884","1638201645.354","1638201644.284","1638201644.047","1638201643.989","1638201643.496","1638201643.395","1638201643.183","1638201643.074","1638201642.951","1638201642.801","1638201642.519","1638201640.536","1638201640.495","1638201639.679","1638201639.616","1638201639.566","1638201639.361","1638201639.357","1638201638.091","1638201637.022","1638201636.501","1638201636.446","1638201636.441","1638201636.357","1638201635.587","1638201635.326","1638201635.324","1638201634.504","1638201633.299","1638201633.267","1638201633.207","1638201632.386","1638201630.017","1638201629.448","1638201629.388","1638201628.803","1638201628.253","1638201627.983","1638201627.928","1638201627.361","1638201626.763","1638201626.584","1638201626.532","1638201625.730","1638201625.392","1638201624.553","1638201623.685","1638201623.682","1638201623.680","1638201623.660","1638201620.751","1638201618.390","1638201617.259","1638201617.192","1638201617.148","1638201617.107","1638201616.227","1638201616.097","1638201615.958","1638201615.857","1638201615.842","1638201615.591","1638201614.538","1638201613.650","1638201613.477","1638201613.469","1638201613.468","1638201613.462","1638201613.431","1638201611.697","1638201610.543","1638201609.388","1638201609.382","1638201606.520","1638201606.030","1638201605.886","1638201605.745","1638201605.581","1638201605.430","1638201605.284","1638201600.651","1638201600.141","null","null","null",% | |
and prints an output like the following to show distribution of times | |
in buckets where each bucket represents a second: | |
2021-11-29 16:02:00: 2 ▇▇ | |
2021-11-29 16:01:59: 1 ▇ | |
2021-11-29 16:01:50: 2 ▇▇ | |
2021-11-29 16:01:49: 1 ▇ | |
2021-11-29 16:01:47: 1 ▇ | |
2021-11-29 16:01:44: 1 ▇ | |
... | |
""" | |
import collections | |
from datetime import datetime | |
import pprint | |
with open('us-east-1/start_times') as file: | |
start_times = [ | |
float(start_time.strip().strip('"')) | |
for start_time in file.read().split(",") | |
if start_time.strip().strip('"') and start_time.strip().strip('"') != "null" | |
] | |
start_times = sorted(start_times, reverse=True) | |
periods = collections.Counter() | |
for i in range(1, len(start_times), 1): | |
periods[int(start_times[i])] += 1 | |
for key, value in periods.items(): | |
val = '▇' * value | |
key = str(datetime.fromtimestamp(key)) | |
print(f"{key}: {str(value).ljust(6)} {val}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment