def request_latency(results, limit):
 scenario_results = [r['scenario'] for r in results if (r['scenario'].get('metrics') and r['scenario']['metrics'].get('call_durations'))]
 if (len(scenario_results) > 0):
  unique_metrics = []
  for result in scenario_results:
   if (result['metrics'] not in unique_metrics):
    unique_metrics.append(result['metrics'])
  total_requests = 0
  requests_under_limit = 0
  for metric in unique_metrics:
   for (duration, num_requests) in metric['call_durations'].iteritems():
    if (float(duration) <= limit):
     requests_under_limit += num_requests
   total_requests += (metric['ok_count'] + metric['err_count'])
  return (float(requests_under_limit) / total_requests)
 return None

def request_latency ( results , limit ) : scenario_results = [ r [ 'scenario' ] for r in results if ( r [ 'scenario' ] . get ( 'metrics' ) and r [ 'scenario' ] [ 'metrics' ] . get ( 'call_durations' ) ) ] if ( len ( scenario_results ) > 0 ) : unique_metrics = [ ] for result in scenario_results : if ( result [ 'metrics' ] not in unique_metrics ) : unique_metrics . append ( result [ 'metrics' ] ) total_requests = 0 requests_under_limit = 0 for metric in unique_metrics : for ( duration , num_requests ) in metric [ 'call_durations' ] . iteritems ( ) : if ( float ( duration ) <= limit ) : requests_under_limit += num_requests total_requests += ( metric [ 'ok_count' ] + metric [ 'err_count' ] ) return ( float ( requests_under_limit ) / total_requests ) return None
calculate the percentage of scenario requests have a latency under the specified time limit .