code: def end_profiling(profiler, filename, sorting=None):
      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())