Metadata-Version: 2.1
Name: timework
Version: 0.1.1
Summary: A package used to set time limits.
Home-page: https://github.com/bugstop/timework-pylib
Author: bugstop
Author-email: pypi@isaacx.com
License: UNKNOWN
Description: # timework
        
        [![PyPI](https://img.shields.io/pypi/v/timework)](https://pypi.org/project/timework/)
        [![python](https://img.shields.io/badge/python-3-blue)](https://www.python.org)
        [![Build Status](https://travis-ci.org/bugstop/timework-pylib.svg?branch=master)](https://travis-ci.org/bugstop/timework-pylib)
        [![Coverage Status](https://coveralls.io/repos/github/bugstop/timework-pylib/badge.svg?branch=master)](https://coveralls.io/github/bugstop/timework-pylib?branch=master)
        [![codebeat badge](https://codebeat.co/badges/3d301de4-a88c-4a8a-9712-373fab3126e4)](https://codebeat.co/projects/github-com-bugstop-timework-pylib-master)
        
        A package used to set time limits.
        
        ## Install
        
        ```
        pip install timework
        ```
        
        ## Usage
        
        ```python
        import timework as tw
        import logging
        
        r = tw.ResultHandler(5)
        
        @tw.timer(r)
        def timer_demo_a():
            i = 0
            while i < 2 ** 23:
                i += 1
            return i
        
        @tw.timer(r, out=print)
        def timer_demo_b():
            i = 0
            while i < 2 ** 24:
                i += 1
            return i
        
        @tw.timer(r, out=logging.warning)
        def timer_demo_c():
            i = 0
            while i < 2 ** 25:
                i += 1
            return i
        
        @tw.limit(3)
        def limit_demo(m):
            i = 0
            while i < 2 ** m:
                i += 1
            return i
        
        @tw.iterative(r, 1)
        def iterative_demo(max_depth):
            i = 0
            while i < 2 ** max_depth:
                i += 1
            return max_depth, i
        
        
        timer_demo_a()
        timer_demo_b()
        timer_demo_c()
        print(r.value, end='\n\n')
        
        try:
            s = limit_demo(4)
        except Exception as e:
            print(e, end='\n\n')
        else:
            print(s)
        
        try:
            s = limit_demo(30)
        except Exception as e:
            print(e, end='\n\n')
        else:
            print(s)
        
        try:
            r.clean()
            iterative_demo(max_depth=10)
        except Exception as e:
            print(e)
        finally:
            print(r.value, end='\n\n')
        
        try:
            r.clean()
            iterative_demo(max_depth=25)
        except Exception as e:
            print(e)
        finally:
            print(r.value, end='\n\n')
        
        ```
        ```
        timer_demo_b: 0.991348 seconds used
        WARNING:root:timer_demo_c: 1.96977 seconds used
        deque([0.5051665306091309, 0.9913477897644043, 1.96976900100708], maxlen=5)
        
        16
        limit_demo: 3 seconds exceeded
        
        deque([(6, 64), (7, 128), (8, 256), (9, 512), (10, 1024)], maxlen=5)
        
        iterative_deepening: 1 seconds exceeded
        deque([(15, 32768), (16, 65536), (17, 131072), (18, 262144), (19, 524288)], maxlen=5)
        
        
        Process finished with exit code 0
        ```
        
        ## License
        
        MIT 漏 <a href="https://github.com/bugstop" style="color:black;text-decoration: none !important;">bugstop</a>
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.4
Description-Content-Type: text/markdown
