diff --git a/README.md b/README.md
index 175931e..acaab24 100644
--- a/README.md
+++ b/README.md
@@ -26,17 +26,19 @@ pip install timework
import timework as tw
```
-### timework.timer
+### Statement `with`
-***A decorator measuring the execution time.***
+#### timework.Stopwatch
-**`timework.TimeError`** contains three parts:
+**Todo**
-- `TimeError.message` ***string,*** \<*decorated function name*\>: \<*time used*\> seconds used
-- `TimeError.result` return values of the function being decorated
-- `TimeError.detail` ***float,*** time used
+### Decorator `@`
-***Notice:*** In **`@timer`** decorator, `timeout` is used to raise a `Error` **after** the decorated function finishes, but fails to finish within `timeout` seconds. If you want to **terminate** the function with a `timeout` limit, please use **`@limit`**.
+**Todo:** read docstrings and tests for more details
+
+#### timework.timer
+
+> measuring the execution time.
```python
import logging
@@ -54,38 +56,24 @@ def timer_demo_b():
while i < 2 ** 24:
i += 1
return i
-
-@tw.timer(timeout=1)
-def timer_demo_c():
- i = 0
- while i < 2 ** 25:
- i += 1
- return i
```
```python
a = timer_demo_a()
b = timer_demo_b()
-try:
- c = timer_demo_c()
-except tw.TimeError as e:
- print('error:', e.message)
- c = e.result
-
-print(a, b, c)
+print(a, b)
```
```
WARNING:root:timer_demo_a: 0.496672 seconds used
START: Tue Feb 18 15:06:45 2020
FINISH: Tue Feb 18 15:06:46 2020
timer_demo_b: 0.989352 seconds used
-error: timer_demo_c: 1.9817 seconds used
-8388608 16777216 33554432
+8388608 16777216
```
-### timework.limit
+#### timework.limit
-***A decorator limiting the execution time.***
+> limiting the execution time.
**`timework.TimeError`** only contains:
@@ -121,8 +109,6 @@ result: 16
limit_demo: 3 seconds exceeded
```
-*You can read docstrings for more details.*
-
## License
-MIT License © bugstop
+MIT License © bugstop
diff --git a/setup.py b/setup.py
index 66f6e8b..7fd9d7c 100644
--- a/setup.py
+++ b/setup.py
@@ -5,7 +5,7 @@
setuptools.setup(
name="timework",
- version="0.3.1",
+ version="0.3.2",
author="bugstop",
author_email="pypi@isaacx.com",
description="measure / limit the function execution time, cross-platform",
diff --git a/timework/__init__.py b/timework/__init__.py
index af09f84..52710de 100644
--- a/timework/__init__.py
+++ b/timework/__init__.py
@@ -1,5 +1,5 @@
"""
-timework 0.3.1
+timework 0.3.2
MIT License © bugstop
@@ -18,5 +18,5 @@
from .timework import *
__name__ = 'timework'
-__version__ = '0.3.1'
+__version__ = '0.3.2'
__all__ = ['timer', 'limit', 'Stopwatch']
diff --git a/timework/test_with-statement.py b/timework/test_with-statement.py
index a4e09be..3c00ace 100644
--- a/timework/test_with-statement.py
+++ b/timework/test_with-statement.py
@@ -1,7 +1,6 @@
from . import timework as tw
import time
-from random import randint
def test_no_split():
"""
diff --git a/timework/timework.py b/timework/timework.py
index 7be1d90..a3fe90f 100644
--- a/timework/timework.py
+++ b/timework/timework.py
@@ -31,7 +31,7 @@ def __init__(self, message: str, result=None, detail=None):
Args:
message: timeout error message
- result: return values of the decorated function (if have)
+ result: return values of the function being decorated
detail: more information (if have)
"""
self.message = message
@@ -57,21 +57,11 @@ def your_function():
Args:
output: A function object that specifies where to log messages.
- For example: print.
+ For example: print. timework.nil does not log messages.
detail: A boolean value, whether to print start and end time.
Returns:
- Exactly the return values of the inner function that is being decorated.
- In this case, the process finishes within [timeout] seconds.
-
- Raises:
- TimeError: This error does not occur until the inner function
- terminates, but fails to finish within [timeout] seconds.
-
- A TimeError object contains:
- TimeError.message: timeout message
- TimeError.result: return values
- TimeError.detail: used run time
+ Exactly the return values of the inner function just as normal.
"""
def decorator(func):
@@ -121,7 +111,7 @@ def your_function():
not yet finishes, then raise TimeError and stop the inner function.
Returns:
- Exactly the return values of the inner function that is being decorated.
+ Exactly the return values of the inner function just as normal.
In this case, the process finishes within [timeout] seconds.
Raises: