nodes: 0, module; 1, function_definition; 2, function_name:end_profiling; 3, parameters; 4, block; 5, identifier:profiler; 6, identifier:filename; 7, default_parameter; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, with_statement; 14, identifier:sorting; 15, None; 16, comment:"""
      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")
      """; 17, call; 18, assignment; 19, assignment; 20, call; 21, with_clause; 22, block; 23, attribute; 24, argument_list; 25, identifier:s; 26, call; 27, identifier:ps; 28, call; 29, attribute; 30, argument_list; 31, with_item; 32, expression_statement; 33, expression_statement; 34, identifier:profiler; 35, identifier:disable; 36, attribute; 37, argument_list; 38, attribute; 39, argument_list; 40, identifier:ps; 41, identifier:print_stats; 42, as_pattern; 43, call; 44, call; 45, identifier:six; 46, identifier:StringIO; 47, call; 48, identifier:sort_stats; 49, identifier:sorting; 50, call; 51, as_pattern_target; 52, attribute; 53, argument_list; 54, attribute; 55, argument_list; 56, attribute; 57, argument_list; 58, identifier:open; 59, argument_list; 60, identifier:f; 61, identifier:_logger; 62, identifier:info; 63, string:"[calculate_ts_features] Finished profiling of time series feature extraction"; 64, identifier:f; 65, identifier:write; 66, call; 67, identifier:pstats; 68, identifier:Stats; 69, identifier:profiler; 70, keyword_argument; 71, identifier:filename; 72, string:"w+"; 73, attribute; 74, argument_list; 75, identifier:stream; 76, identifier:s; 77, identifier:s; 78, identifier:getvalue
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 = six.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())