Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
PHP Average Latency By Week
from datetime import datetime
import matplotlib.pyplot as plt
import traceview
API_KEY = 'API KEY HERE'
def main():
tv = traceview.TraceView(API_KEY)
results = tv.server.latency_by_layer('Default', time_window='week')
# get the php layer
php = next((x for x in results if x.get('layer') == 'PHP'), None)
# convert timestamps to datetime objects
dates = [datetime.utcfromtimestamp(i[0]) for i in php['timeseries']['items']]
# calculate average latency (total_latency / volume) and convert to
# milliseconds
average_latency = [((i[2] / i[1]) / 1000) for i in php['timeseries']['items']]
# create a matplotlib plot
plt.figure(figsize=(12, 5), dpi=80)
plt.stackplot(dates, average_latency, colors=['#1dacd6'])
plt.title('PHP Average Latency (ms) - by Week')
plt.savefig('latency.png')
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.