Skip to content
Snippets Groups Projects
Select Git revision
  • 26650f6fe4019020c4b78ff92a7745bbe23d64f5
  • master default protected
2 results

pyTiming

  • Clone with SSH
  • Clone with HTTPS
  • David Beniamine's avatar
    David Beniamine authored
    26650f6f
    History

    Python timing

    This is a simple libraire to do fine timing of python application and measure parallelism

    Install

    pip

    pip3 install git+https://gitlab.tetras-libre.fr/tetras-libre/performance-analysis/pyTiming#egg=pyTiming

    For developpement

    git clone https://gitlab.tetras-libre.fr/tetras-libre/performance-analysis/pyTiming
    pip3 install -e .

    As a dependency in your setup.py

    from setuptools.command.install import install
    from setuptools.command.develop import develop
    from setuptools import setup, find_packages
    import pip
    
    ...
    
    gitDeps = [
    'git+https://gitlab.tetras-libre.fr/tetras-libre/performance-analysis/pyTiming#egg=pyTiming',
        ]
    
    
    def customRun(command_subclass):
        orig_run = command_subclass.run
    
        def modified_run(self):
            for dep in gitDeps:
                pip.main(['install', dep])
    
            orig_run(self)
    
        command_subclass.run = modified_run
        return command_subclass
    
    @customRun
    class actionsOnInstall(install):
        pass
    
    
    @customRun
    class actionsOnDevelop(develop):
        pass
    
    ...
    
    setup(
    ...
        cmdclass={'install': actionsOnInstall,
                  'develop': actionsOnDevelop,
    ...
    )
    

    Usage

    from pyTiming.pyTiming import timer
    timer = timer() # starts measuring time
    . . .
    
    timer.start_step('step1')
    . . .
    timer.start_step('step1.1')
    . . .
    timer.end_step('step1.1')
    timer.start_step('step1.2')
    . . .
    timer.end_step('step1.2')
    timer.end_step('step1')
    
    timer.start_step('step2')
    . . .
    timer.end_step('step2')
    
    timer.end() # end all measurements
    
    print(timer.get_analysis())