Skip to content

Profiler

profile(filename=None, comm=mpi_comm)

Parameters:

Name Type Description Default
filename

(Default value = None)

None
comm

(Default value = mpi_comm)

mpi_comm
Source code in june/utils/profiler.py
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
def profile(filename=None, comm=mpi_comm):
    """

    Args:
        filename: (Default value = None)
        comm: (Default value = mpi_comm)

    """
    def prof_decorator(f):
        """

        Args:
            f: 

        """
        def wrap_f(*args, **kwargs):
            """

            Args:
                *args: 
                **kwargs: 

            """
            pr = cProfile.Profile()
            pr.enable()
            result = f(*args, **kwargs)
            pr.disable()

            if filename is None:
                pr.print_stats()
            else:
                filename_r = filename + ".{}".format(mpi_rank)
                pr.dump_stats(filename_r)

            return result

        return wrap_f

    return prof_decorator