Prints all of the child function profiler results to a given file. (stdout by default)
194476
def print_all(self, out=sys.stdout):
        
        if self.empty():
            return
        
        FUNC_NAME_LEN = 38
        CALLCOUNT_LEN = 9        
        out.write(CRLF)
        out.write("name                                    #n         tsub      ttot      tavg")
        out.write(CRLF)
        for stat in self:
            out.write(StatString(stat.full_name).ltrim(FUNC_NAME_LEN))
            out.write(" " * COLUMN_GAP)
            
            # the function is recursive?
            if stat.is_recursive():
                out.write(StatString("%d/%d" % (stat.ncall, stat.nactualcall)).rtrim(CALLCOUNT_LEN))
            else:
                out.write(StatString(stat.ncall).rtrim(CALLCOUNT_LEN))
            out.write(" " * COLUMN_GAP)
            out.write(StatString(_fft(stat.tsub)).rtrim(TIME_COLUMN_LEN))
            out.write(" " * COLUMN_GAP)
            out.write(StatString(_fft(stat.ttot)).rtrim(TIME_COLUMN_LEN))
            out.write(" " * COLUMN_GAP)
            out.write(StatString(_fft(stat.tavg)).rtrim(TIME_COLUMN_LEN))
            out.write(CRLF)
602167
def _print_results(filename, data):
    
    if filename:
        with open(filename, 'wb') as f:
            f.write(data)
    else:
        print data
33776
def print_subtree(self, fobj=sys.stdout, level=0):
        """"""
        fobj.write("{}{!r}\n".format(" " * (level * 2), self))
        for child in self.get_children():
            child.print_subtree(fobj, level + 1)
851037
def print_results(cls, stdout, stderr):
        """"""
        for line in stderr:
            print(line, file=sys.stderr)
        if stdout:
            if stderr:  # blank line to separate stdout from stderr
                print(file=sys.stderr)
            cls._print_stdout(stdout)
        else:
            print(':) No issues found.')
1177080
def printData(self, output = sys.stdout):
		""""""
		self.printDatum("Name          : ", self.fileName, output)
		self.printDatum("Author        : ", self.author, output)
		self.printDatum("Repository    : ", self.repository, output)
		self.printDatum("Category      : ", self.category, output)
		self.printDatum("Downloads     : ", self.downloads, output)
		self.printDatum("Date Uploaded : ", self.fileDate, output)
		self.printDatum("File Size     : ", self.fileSize, output)
		self.printDatum("Documentation : ", self.documentation, output)
		self.printDatum("Source Code   : ", self.sourceCode, output)
		self.printDatum("Description   : ", self.description, output)
#		print("\n", output)
		print >> output, "\n\n"
1097588
def print_children_recursively(all_items, for_item, level):
    
    children = [child for child in all_items if child.parentid == for_item.id]
    for child in children:
        #message = f"{for_item.name}({for_item.id}) is a parent to {child.name}({child.id})"
        indent = " " * level * 2
        id_col = f"{indent} {child.id}"
        print_row(id_col, child.name, f"{child.allocation:,.2f}", level)

        # Process children.
        print_children_recursively(all_items, child, level+1)
1155420
def parseprofile(profilelog, out):
    '''
    
    '''
    file = open(out, 'w') # opening the output file
    print('Opening the profile in %s...' % profilelog)
    p = pstats.Stats(profilelog, stream=file) # parsing the profile with pstats, and output everything to the file

    print('Generating the stats, please wait...')
    file.write("=== All stats:\n")
    p.strip_dirs().sort_stats(-1).print_stats()
    file.write("=== Cumulative time:\n")
    p.sort_stats('cumulative').print_stats(100)
    file.write("=== Time:\n")
    p.sort_stats('time').print_stats(100)
    file.write("=== Time + cumulative time:\n")
    p.sort_stats('time', 'cum').print_stats(.5, 'init')
    file.write("=== Callees:\n")
    p.print_callees()
    file.write("=== Callers:\n")
    p.print_callers()
    #p.print_callers(.5, 'init')
    #p.add('fooprof')
    file.close()
    print('Stats generated and saved to %s.' % out)
    print('Everything is done. Exiting')
1000426
def print_output(self, dotdata, output_file=None):
        """"""
        if six.PY3 and isinstance(dotdata, six.binary_type):
            dotdata = dotdata.decode()

        if output_file:
            with open(output_file, 'wt') as dot_output_f:
                dot_output_f.write(dotdata)
        else:
            self.stdout.write(dotdata)
308059
def dump_children(self, f, indent=''):
        """"""
        for child in self.__order:
            child.dump(f, indent+'  ')
300516
def profiler():
    ''''''
    import cProfile
    import pstats
    pr = cProfile.Profile()
    pr.enable()
    yield
    pr.disable()
    ps = pstats.Stats(pr).sort_stats('tottime')
    ps.print_stats()
797208
def write_output_files(self, fh):
    
    for f in self.__output_files:
        print >>fh, "## Job %s generates output file %s" % (self.__name, f)
708435
def _print_breakdown(cls, savedir, fname, data):
        """"""
        if not os.path.exists(savedir):
            os.makedirs(savedir)

        with open(os.path.join(savedir, fname), 'w') as fout:
            fout.write(data)
835034
function output() {
        var sortByKey = options.sortByKey;
        if (sortByKey) {
          var keys = Object.keys(json),
            i, k, len = keys.length,
            tmp = {};
          keys.sort();
          for (i = 0; i < len; i++) {
            k = keys[i];
            tmp[k] = json[k];
          }
          json = tmp;
          tmp = null;
        }
        grunt.file.write(outputFile, JSON.stringify(json, null, 4));
        done();
      }
1196259
def _stage_output_files(self, file_mapping, dry_run=True):
        """"""
        # print ("Staging output ", file_mapping)
        if self._file_stage is None:
            return
        self._file_stage.copy_from_scratch(file_mapping, dry_run)
345101
def _output(self, file_like_object, path=None):
        """"""
        if not path:
            self._output_to_display(file_like_object)
        else:
            self._output_to_file(file_like_object, path)
192759
def dump(self, target=sys.stdout):
        
        for r in self.result:
            r.dump(target=target)
1139313
def handler_profiler(filename=None):
    
    if filename == None:
        f = sys.stdout
    else:
        f = open(filename, 'w')
    def _callfunc(handle):
        @wraps(handle)
        def func(self, topic, msg):
            t0 = time.time()
            handle(self, topic, msg)
            t1 = time.time()
            print(f'{self.name}-handle运行时间:{t1 - t0}s', file=f)

        return func
    return _callfunc