code: def generate_lookup_perf_test(ducet):
      chunk_size = 50
      chunks_per_file = 100
  
      chunk_arrays = []
  
      chunk = 0
      i = 0
      cps = []
      cp_ranges = []
      for k, v in sorted(ducet.items()):
          cp_ranges.append((len(cps), len(cps) + len(k)))
          cps += list(k)
          i += 1
          if i == chunk_size:
              chunk_arrays.append((cps, cp_ranges))
              chunk += 1
              i = 0
              cps = []
              cp_ranges = []
  
      chunk_idx = 0
      lines = ""
      for i in range(len(chunk_arrays)):
          if i != 0 and i % chunks_per_file == 0:
              cpp_file = open(
                  "collation_element_lookup_perf_{0:03}.cpp".format(
                      chunk_idx
                  ),
                  "w",
              )
              cpp_file.write(perf_test_form.format(lines))
              chunk_idx += 1
              lines = ""
          cps = chunk_arrays[i][0]
          cp_ranges = chunk_arrays[i][1]
          lines += """\
  uint32_t cps_{0:03}[] = {{
  {1}
  }};
  
  void BM_collation_element_lookup_{0:03}(benchmark::State & state)
  {{
      while (state.KeepRunning()) {{
  """.format(
              i,
              ", ".join(
                  map(
                      lambda x: type(x) == str and "0x" + x or hex(x),
                      cps,
                  )
              ),
              len(cps),
          )
          for first, last in cp_ranges:
              lines += """\
              benchmark::DoNotOptimize(trie().longest_match(cps_{0:03} + {1}, cps_{0:03} + {2}));
  """.format(
                  i, first, last
              )
          lines += """\
      }}
  }}
  BENCHMARK(BM_collation_element_lookup_{0:03});
  
  """.format(
              i
          )
  
      cpp_file = open(
          "collation_element_lookup_perf_{0:03}.cpp".format(chunk_idx),
          "w",
      )
      cpp_file.write(perf_test_form.format(lines))
  
file_path: infinity/third_party/iresearch/external/text/scripts/generate_unicode_collation_tests.py
imports: from generate_unicode_normalization_data import cccs
  from generate_unicode_normalization_data import expand_decomp_canonical
  from generate_unicode_normalization_data import get_decompositions
  from generate_unicode_collation_data import get_frac_uca_cet
  from generate_unicode_collation_data import ce_to_cpp
  import re
  import sys
label_desc: Use image node_id 2 for calling a global function with example usage: generate_lookup_perf_test(ducet) without return types