code: def parse_wrk_decoded_stdout(decoded_out):
      """
      Parse decoded wrk stdout to a dictionary.
  
      # Sample wrk stdout:
      #
      Running 10s test @ http://127.0.0.1:8000/echo
      8 threads and 96 connections
      Thread Stats   Avg      Stdev     Max   +/- Stdev
          Latency    72.32ms    6.00ms 139.00ms   91.60%
          Req/Sec   165.99     34.84   242.00     57.20%
      Latency Distribution
          50%   70.78ms
          75%   72.59ms
          90%   75.67ms
          99%   98.71ms
      13306 requests in 10.10s, 1.95MB read
      Requests/sec:   1317.73
      Transfer/sec:    198.19KB
  
      Returns:
          {'latency_avg_ms': 72.32, 'latency_stdev_ms': 6.0,
           'latency_max_ms': 139.0, 'latency_+/-_stdev %': 91.6,
          'req/sec_avg': 165.99, 'req/sec_stdev': 34.84,
          'req/sec_max': 242.0, 'req/sec_+/-_stdev %': 57.2,
          'P50_latency_ms': 70.78, 'P75_latency_ms': 72.59,
          'P90_latency_ms': 75.67, 'P99_latency_ms': 98.71,
          'requests/sec': 1317.73, 'transfer/sec_KB': 198.19
      """
      metrics_dict = {}
      for line in decoded_out.splitlines():
          parsed = re.split(r"\s+", line.strip())
          # Statistics section
          # Thread Stats   Avg      Stdev     Max   +/- Stdev
          #   Latency    72.32ms    6.00ms 139.00ms   91.60%
          #   Req/Sec   165.99     34.84   242.00     57.20%
          if parsed[0] == "Latency" and len(parsed) == 5:
              metrics_dict[
                  "per_thread_latency_avg_ms"
              ] = parse_time_to_ms(parsed[1])
              metrics_dict[
                  "per_thread_latency_max_ms"
              ] = parse_time_to_ms(parsed[3])
          elif parsed[0] == "Req/Sec" and len(parsed) == 5:
              metrics_dict["per_thread_tps"] = parse_metric_to_base(
                  parsed[1]
              )
              metrics_dict["per_thread_max_tps"] = parse_metric_to_base(
                  parsed[3]
              )
          # Latency Distribution header, ignored
          elif parsed[0] == "Latency" and parsed[1] == "Distribution":
              continue
          # Percentile section
          # 50%   70.78ms
          # 75%   72.59ms
          # 90%   75.67ms
          # 99%   98.71ms
          elif parsed[0] == "50%":
              metrics_dict["P50_latency_ms"] = parse_time_to_ms(
                  parsed[1]
              )
          elif parsed[0] == "75%":
              metrics_dict["P75_latency_ms"] = parse_time_to_ms(
                  parsed[1]
              )
          elif parsed[0] == "90%":
              metrics_dict["P90_latency_ms"] = parse_time_to_ms(
                  parsed[1]
              )
          elif parsed[0] == "99%":
              metrics_dict["P99_latency_ms"] = parse_time_to_ms(
                  parsed[1]
              )
          # Total requests and transfer (might have timeout too)
          # 13306 requests in 10.10s, 1.95MB read
          elif len(parsed) >= 6 and parsed[1] == "requests":
              metrics_dict["per_node_total_thoughput"] = int(parsed[0])
              metrics_dict[
                  "per_node_total_transfer_KB"
              ] = parse_size_to_KB(parsed[4])
          # Socket errors: connect 0, read 0, write 0, timeout 100
          elif parsed[0] == "Socket" and parsed[1] == "errors:":
              metrics_dict[
                  "per_node_total_timeout_requests"
              ] = parse_metric_to_base(parsed[-1])
          # Summary section
          # Requests/sec:   1317.73
          # Transfer/sec:    198.19KB
          elif parsed[0] == "Requests/sec:":
              metrics_dict["per_nodel_tps"] = parse_metric_to_base(
                  parsed[1]
              )
          elif parsed[0] == "Transfer/sec:":
              metrics_dict[
                  "per_node_transfer_per_sec_KB"
              ] = parse_size_to_KB(parsed[1])
  
      return metrics_dict
  
file_path: ray/release/serve_tests/workloads/serve_test_utils.py
imports: import json
  import logging
  import os
  import random
  import ray
  import re
  import subprocess
  from collections import defaultdict
  from serve_test_cluster_utils import NUM_CPU_PER_NODE
  from subprocess import PIPE
  from typing import Dict, List, Union
label_desc: Use image node_id 5 for calling a global function with example usage: parse_wrk_decoded_stdout(decoded_out) and returns: metrics_dict