in src/graphing/allocation_rate.py [0:0]
def get_difference(before_list, after_list, time, interval_duration, percentile):
times = []
difference_list = []
# Explains how to measure allocation rate
# https://plumbr.io/handbook/gc-tuning-in-practice/high-allocation-rate
interval_start_time = time[0]
allocated_bytes = 0
if percentile is None or interval_duration is None:
for index in range(len(before_list) - 1):
allocated_bytes += before_list[index + 1] - after_list[index]
elapsed_seconds = time[index + 1] - interval_start_time
if (interval_duration is None or elapsed_seconds >= interval_duration):
if elapsed_seconds != 0:
difference_list.append(allocated_bytes / elapsed_seconds)
times.append(time[index])
allocated_bytes = 0
interval_start_time = time[index + 1]
return times, difference_list
else:
# If we have a percentile, we have groupings based on time intervals
import numpy as np
allocated_bytes_rate= []
percentile_array = []
# Create a list of all allocation rates within a time interval.
# Then, take the percentile from that list. Return a list of these percentiles, and associated timestamps
for index in range( len(before_list) - 1):
time_delta = (time[index + 1] - time[index])
if time_delta != 0:
allocated_bytes_rate.append((before_list[index + 1] - after_list[index]) / time_delta)
elapsed_seconds = time[index + 1] - interval_start_time
if (elapsed_seconds >= interval_duration):
times.append(time[index]) # Set the timestamp for this time interval
percentile_array.append(np.percentile(allocated_bytes_rate, percentile))
interval_start_time = time[index + 1]
allocated_bytes_rate = []
return times, percentile_array