code: def test_percentile_report():
      def gen_callback(data):
          def callback(value):
              data.append(value)
  
          return callback
  
      data90 = []
      data95 = []
      data99 = []
  
      all_data = []
      percentile_args = [
          (Percentile.PercentileType.P90, gen_callback(data90), 100),
          (Percentile.PercentileType.P95, gen_callback(data95), 100),
          (Percentile.PercentileType.P99, gen_callback(data99), 100),
      ]
      percentile_list = [
          _percentile_builder[percentile_type](callback, window)
          for percentile_type, callback, window in percentile_args
      ]
      for _ in range(199):
          data = random()
          all_data.append(data)
          for percentile in percentile_list:
              percentile.record_data(data)
      sub_data = sorted(all_data[:100])
      print(sub_data[:10])
      assert len(data90) == 1 and sub_data[10 - 1] == data90[0]
      assert len(data95) == 1 and sub_data[5 - 1] == data95[0]
      assert len(data99) == 1 and sub_data[1 - 1] == data99[0]
  
file_path: mars/mars/metrics/tests/test_metric_api.py
imports: import pytest
  from random import random
  from ..None import api
  from ..api import init_metrics, Metrics, _percentile_builder, Percentile, record_time_cost_percentile, shutdown_metrics
label_desc: Use image node_id 7 for calling a global function with example usage: test_percentile_report() and returns: callback