'Stop profiling and print profile information to sys.stderr.
This function is registered as an atexit hook.'

def atexit(self):

    funcname = self.fn.__name__
    filename = self.fn.func_code.co_filename
    lineno = self.fn.func_code.co_firstlineno
    print
    print '***    COVERAGE    RESULTS    ***'
    print ('%s    (%s:%s)' % (funcname, filename, lineno))
    print ('function    called    %d    times' % self.ncalls)
    print
    fs = FuncSource(self.fn)
    for ((filename, lineno), count) in self.tracer.counts.items():
        if (filename != fs.filename):
            continue
        fs.mark(lineno, count)
    print fs
    never_executed = fs.count_never_executed()
    if never_executed:
        print ('%d    lines    were    not    executed.' % never_executed)
