@@ -0,0 +1,1460 @@
+%22%22%22%0AAuthor: Jharrod LaFon%0ASee also: https://github.com/jlafon/ansible-profile%0A%22%22%22%0A%0Aimport time%0A%0A%0Aclass CallbackModule(object):%0A    %22%22%22%0A    A plugin for timing tasks%0A    %22%22%22%0A    def __init__(self):%0A        self.stats = %7B%7D%0A        self.current = None%0A%0A    def playbook_on_task_start(self, name, is_conditional):%0A        %22%22%22%0A        Logs the start of each task%0A        %22%22%22%0A        if self.current is not None:%0A            # Record the running time of the last executed task%0A            self.stats%5Bself.current%5D = time.time() - self.stats%5Bself.current%5D%0A%0A        # Record the start time of the current task%0A        self.current = name%0A        self.stats%5Bself.current%5D = time.time()%0A%0A    def playbook_on_stats(self, stats):%0A        %22%22%22%0A        Prints the timings%0A        %22%22%22%0A        # Record the timing of the very last task%0A        if self.current is not None:%0A            self.stats%5Bself.current%5D = time.time() - self.stats%5Bself.current%5D%0A%0A        # Sort the tasks by their running time%0A        results = sorted(%0A            self.stats.items(),%0A            key=lambda value: value%5B1%5D,%0A            reverse=True,%0A        )%0A%0A        # Just keep the top 10%0A        results = results%5B:10%5D%0A%0A        print%0A%0A        # Print the timings%0A        for name, elapsed in results:%0A            print(%0A                %22%7B0:-%3C70%7D%7B1:-%3E9%7D%22.format(%0A                    '%7B0%7D '.format(name),%0A                    ' %7B0:.02f%7Ds'.format(elapsed),%0A                )%0A            )%0A%0A        print%0A

Add Ansible callback plugin to profile tasks