docs: def annotate(self, out, filename=None, commandline=None, relative_path=False):
          """
          Dump annotated source code with current profiling statistics to "out"
          file.
          Time unit: second.
          out (file-ish opened for writing)
              Destination of annotated sources.
          filename (str, list of str)
              If provided, dump stats for given source file(s) only.
              By default, list for all known files.
          commandline (anything with __str__)
              If provided, will be output as the command line used to generate
              this annotation.
          relative_path (bool)
              For compatibility with callgrind. Ignored.
          """
          file_dict = self.file_dict
          total_time = self.total_time
          if commandline is not None:
              print >> out, 'Command line:', commandline
          print >> out, 'Total duration: %gs' % total_time
          if not total_time:
              return
          def percent(value, scale):
              if scale == 0:
                  return 0
              return value * 100 / float(scale)
          for name in self._getFileNameList(filename):
              file_timing = file_dict[name]
              file_total_time = file_timing.getTotalTime()
              call_list_by_line = file_timing.getCallListByLine()
              print >> out, 'File:', name
              print >> out, 'File duration: %gs (%.2f%%)' % (file_total_time,
                  percent(file_total_time, total_time))
              print >> out, _ANNOTATE_HEADER
              print >> out, _ANNOTATE_HORIZONTAL_LINE
              for lineno, _, _, hits, duration, line in self._iterFile(name,
                      call_list_by_line):
                  if hits:
                      time_per_hit = duration / hits
                  else:
                      time_per_hit = 0
                  print >> out, _ANNOTATE_FORMAT % {
                      'lineno': lineno,
                      'hits': hits,
                      'time': duration,
                      'time_per_hit': time_per_hit,
                      'percent': percent(duration, total_time),
                      'line': line,
                  },
                  for _, _, hits, duration, callee_file, callee_line, \
                          callee_name in call_list_by_line.get(lineno, ()):
                      print >> out, _ANNOTATE_CALL_FORMAT % {
                          'hits': hits,
                          'time': duration,
                          'time_per_hit': duration / hits,
                          'percent': percent(duration, total_time),
                          'callee_file': callee_file,
                          'callee_line': callee_line,
                          'callee_name': callee_name,
                      }