Add examples for measure time
This commit is contained in:
parent
2527c60ed0
commit
081a4fe05f
|
@ -207,6 +207,21 @@ Date and times
|
|||
|
||||
app.msgbox(app.now(True))
|
||||
|
||||
* Get `epoch time`_
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
app.msgbox(app.get_epoch())
|
||||
|
||||
* Simple measure time
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
app.start()
|
||||
app.sleep(5)
|
||||
seconds = app.end(True)
|
||||
app.msgbox(seconds)
|
||||
|
||||
|
||||
Thread
|
||||
^^^^^^
|
||||
|
@ -472,3 +487,7 @@ You can save any data.
|
|||
data = app.get_config('config', my_app)
|
||||
|
||||
app.msgbox(data)
|
||||
|
||||
|
||||
|
||||
.. _epoch time: https://en.wikipedia.org/wiki/Unix_time
|
||||
|
|
|
@ -692,7 +692,7 @@ def sha512(data):
|
|||
result = hashlib.sha512(data.encode()).hexdigest()
|
||||
return result
|
||||
|
||||
# ~ todo
|
||||
|
||||
def get_config(key='', prefix='conf', default={}):
|
||||
name_file = FILE_NAME_CONFIG.format(prefix)
|
||||
values = None
|
||||
|
@ -718,6 +718,7 @@ def set_config(key, value, prefix='conf'):
|
|||
|
||||
def start():
|
||||
global _start
|
||||
|
||||
_start = now()
|
||||
info(_start)
|
||||
return
|
||||
|
@ -725,6 +726,7 @@ def start():
|
|||
|
||||
def end(get_seconds: bool=False):
|
||||
global _start
|
||||
|
||||
e = now()
|
||||
td = e - _start
|
||||
result = str(td)
|
||||
|
@ -770,7 +772,7 @@ def url_open(url, data=None, headers={}, verify=True, get_json=False):
|
|||
response = urlopen(req, data=data)
|
||||
else:
|
||||
context = ssl._create_unverified_context()
|
||||
response = urlopen(req, context=context)
|
||||
response = urlopen(req, data=data, context=context)
|
||||
except HTTPError as e:
|
||||
error(e)
|
||||
err = str(e)
|
||||
|
|
Loading…
Reference in New Issue