class_docstr: Record type for benchmark times
class_docstr_tok: ["Record","type","for","benchmark","times"]
docstr: Return ``str`` with the TSV representation of this record
docstr_tok: ["Return","``","str","``","with","the","TSV","representation","of","this","record"]
code: def to_tsv(self):
      """Return ``str`` with the TSV representation of this record"""
  
      def to_tsv_str(x):
          """Conversion of value to str for TSV (None becomes "-")"""
          if x is None:
              return "-"
          elif isinstance(x, float):
              return f"{x:.2f}"
          else:
              return str(x)
  
      def timedelta_to_str(x):
          """Conversion of timedelta to str without fractions of seconds"""
          mm, ss = divmod(x.seconds, 60)
          hh, mm = divmod(mm, 60)
          s = "%d:%02d:%02d" % (hh, mm, ss)
          if x.days:
  
              def plural(n):
                  return n, abs(n) != 1 and "s" or ""
  
              s = ("%d day%s, " % plural(x.days)) + s
          return s
  
      if self.skipped_procs:
          logger.debug(
              "Benchmark: not collected for "
              "; ".join(
                  [
                      f"{{'pid': {record[0]}, 'name': '{record[1]}''}}"
                      for record in self.skipped_procs
                  ]
              )
          )
          logger.debug(
              "Benchmark: collected for "
              "; ".join(
                  [
                      f"{{'pid': {record[0]}, 'name': '{record[1]}'}}"
                      for record in self.processed_procs
                  ]
              )
          )
      if self.data_collected:
          return "\t".join(
              map(
                  to_tsv_str,
                  (
                      f"{self.running_time:.4f}",
                      timedelta_to_str(
                          datetime.timedelta(seconds=self.running_time)
                      ),
                      self.max_rss,
                      self.max_vms,
                      self.max_uss,
                      self.max_pss,
                      self.io_in,
                      self.io_out,
                      self.cpu_usages / self.running_time,
                      self.cpu_time,
                  ),
              )
          )
      else:
          # If no data has been collect mem and cpu statistics will be printed as NA
          # to make it possible to distinguish this case from processes that complete instantly
          logger.warning(
              "Benchmark: unable to collect cpu and memory benchmark statistics"
          )
          return "\t".join(
              [
                  f"{self.running_time:.4f}",
                  timedelta_to_str(
                      datetime.timedelta(seconds=self.running_time)
                  ),
                  "NA",
                  "NA",
                  "NA",
                  "NA",
                  "NA",
                  "NA",
                  "NA",
                  "NA",
              ]
          )
  
imports: import contextlib
  import datetime
  from itertools import chain
  import os
  import time
  import threading
  from snakemake.logging import logger
label_desc: Use image node_id 3 for calling the BenchmarkRecord obj's underlying member method code with example usage: obj.to_tsv() and returns: s, str, str, str, x, str, n,  unknown