code: def end_profiling(profiler, filename, sorting=None):
      """
      Helper function to stop the profiling process and write out the profiled
      data into the given filename. Before this, sort the stats by the passed sorting.
  
      :param profiler: An already started profiler (probably by start_profiling).
      :type profiler: cProfile.Profile
      :param filename: The name of the output file to save the profile.
      :type filename: basestring
      :param sorting: The sorting of the statistics passed to the sort_stats function.
      :type sorting: basestring
  
      :return: None
      :rtype: None
  
      Start and stop the profiler with:
  
      >>> profiler = start_profiling()
      >>> # Do something you want to profile
      >>> end_profiling(profiler, "out.txt", "cumulative")
      """
      profiler.disable()
      s = io.StringIO()
      ps = pstats.Stats(profiler, stream=s).sort_stats(sorting)
      ps.print_stats()
  
      with open(filename, "w+") as f:
          _logger.info(
              "[calculate_ts_features] Finished profiling of time series feature extraction"
          )
          f.write(s.getvalue())
  
file_path: tsfresh/tsfresh/utilities/profiling.py
imports: import cProfile
  import io
  import logging
  import pstats
  from tsfresh import defaults
label_desc: Use image node_id 2 for calling a global function with example usage: end_profiling(profiler, filename, sorting) without return types