# tictectoc
Tic Tec Toc timing for Python.
## How to install
```
pip install tictectoc
```
## TicTecToc
1. TicToc
```
import time
from tictectoc import TicTecToc
t = TicTecToc()
t.tic()
time.sleep(1)
t.toc() # print '[TTT:default] Elapsed time is 0:00:01'
t.tic()
time.sleep(2)
t.toc() # print '[TTT:default] Elapsed time is 0:00:02'
```
2. TicTecToc
```
import time
from tictectoc import TicTecToc
t = TicTecToc()
for i in range(10):
t.tic()
time.sleep(1)
t.tec()
t.toc() # print '[TTT:default] Elapsed time is 0:00:10'
```
3. (a) TicTecToc with more than 1 timers
```
import time
from tictectoc import TicTecToc
t = TicTecToc()
t2 = TicTecToc('timer2')
for i in range(10):
t.tic('timer0')
t.tic('timer1')
t.tic(100)
t2.tic()
time.sleep(1)
t.tec('timer0')
t.tec('timer1')
t.tec(100)
t2.tec()
t.toc('timer0') # print '[TTT:timer0] Elapsed time is 0:00:10'
t.toc('timer1') # print '[TTT:timer1] Elapsed time is 0:00:10'
t.toc(100) # print '[TTT:100] Elapsed time is 0:00:10'
t2.toc() # print '[TTT:timer2] Elapsed time is 0:00:10'
```
4. global instance 'ttt'
```
import time
from tictectoc import ttt
for i in range(10):
ttt.tic()
time.sleep(1)
ttt.tec()
ttt.toc() # print '[TTT:default] Elapsed time is 0:00:10'
```
5. global function 'tic, tec, toc'
```
import time
from tictectoc import tic, tec, toc
for i in range(10):
tic()
time.sleep(1)
tec()
toc() # print '[TTT:default] Elapsed time is 0:00:10'
```
5. abbreviation
```
import time
from tictectoc import TicTecToc
t = TicTecToc()
for i in range(10):
t.i()
time.sleep(1)
t.e()
t.o() # print '[TTT:default] Elapsed time is 0:00:10'
```
```
import time
from tictectoc import ttt
for i in range(10):
ttt.i()
time.sleep(1)
ttt.e()
ttt.o() # print '[TTT:default] Elapsed time is 0:00:10'
```
```
import time
from tictectoc import i, e, o
for i in range(10):
i()
time.sleep(1)
e()
o() # print '[TTT:default] Elapsed time is 0:00:10'
```
6. decorator
```
import time
from tictectoc import ttt
@ttt.dec('timer0')
def function(n=10):
for i in range(n):
time.sleep(1)
function() # print '[TTT:timer0] Elapsed time is 0:00:10'
```
```
import time
from tictectoc import dec
@dec('timer0')
def function(n=1):
for i in range(n):
time.sleep(1)
function() # print '[TTT:timer0] Elapsed time is 0:00:10'
```
7. (a) with statement
```
import time
from tictectoc import TicTecToc
with TicTecToc():
for i in range(10):
time.sleep(1)
# print '[TTT::default] Elapsed time is 0:00:10'
```
```
import time
from tictectoc import ttt
with ttt:
for i in range(10):
time.sleep(1)
# print '[TTT::default] Elapsed time is 0:00:10'
```
7. (b) double with
```
import time
from tictectoc import TicTecToc
with TicTecToc('timer0'):
with TicTecToc('timer1'):
time.sleep(10)
time.sleep(10)
# print '[TTT::timer1] Elapsed time is 0:00:10'
# print '[TTT::timer0] Elapsed time is 0:00:20'
```
Raw data
{
"_id": null,
"home_page": "https://github.com/nemodleo/tictectoc",
"name": "tictectoc",
"maintainer": "",
"docs_url": null,
"requires_python": ">= 3.6",
"maintainer_email": "",
"keywords": "tic tec toc tictoc tictectoc time timing",
"author": "Hyun Park",
"author_email": "nemod.leo@snu.ac.kr",
"download_url": "",
"platform": null,
"description": "# tictectoc\nTic Tec Toc timing for Python.\n\n\n## How to install\n```\npip install tictectoc\n```\n\n## TicTecToc\n1. TicToc\n```\nimport time\nfrom tictectoc import TicTecToc\nt = TicTecToc()\nt.tic()\ntime.sleep(1)\nt.toc() # print '[TTT:default] Elapsed time is 0:00:01'\n\nt.tic()\ntime.sleep(2)\nt.toc() # print '[TTT:default] Elapsed time is 0:00:02'\n```\n\n\n2. TicTecToc\n```\nimport time\nfrom tictectoc import TicTecToc\nt = TicTecToc()\nfor i in range(10):\n t.tic()\n time.sleep(1)\n t.tec()\nt.toc() # print '[TTT:default] Elapsed time is 0:00:10'\n```\n\n\n3. (a) TicTecToc with more than 1 timers\n```\nimport time\nfrom tictectoc import TicTecToc\nt = TicTecToc()\nt2 = TicTecToc('timer2')\nfor i in range(10):\n t.tic('timer0')\n t.tic('timer1')\n t.tic(100)\n t2.tic()\n time.sleep(1)\n t.tec('timer0')\n t.tec('timer1')\n t.tec(100)\n t2.tec()\nt.toc('timer0') # print '[TTT:timer0] Elapsed time is 0:00:10'\nt.toc('timer1') # print '[TTT:timer1] Elapsed time is 0:00:10'\nt.toc(100) # print '[TTT:100] Elapsed time is 0:00:10'\nt2.toc() # print '[TTT:timer2] Elapsed time is 0:00:10'\n```\n\n\n4. global instance 'ttt'\n```\nimport time\nfrom tictectoc import ttt\nfor i in range(10):\n ttt.tic()\n time.sleep(1)\n ttt.tec()\nttt.toc() # print '[TTT:default] Elapsed time is 0:00:10'\n```\n\n\n5. global function 'tic, tec, toc'\n```\nimport time\nfrom tictectoc import tic, tec, toc\nfor i in range(10):\n tic()\n time.sleep(1)\n tec()\ntoc() # print '[TTT:default] Elapsed time is 0:00:10'\n```\n\n\n5. abbreviation\n```\nimport time\nfrom tictectoc import TicTecToc\nt = TicTecToc()\nfor i in range(10):\n t.i()\n time.sleep(1)\n t.e()\nt.o() # print '[TTT:default] Elapsed time is 0:00:10'\n```\n```\nimport time\nfrom tictectoc import ttt\nfor i in range(10):\n ttt.i()\n time.sleep(1)\n ttt.e()\nttt.o() # print '[TTT:default] Elapsed time is 0:00:10'\n```\n```\nimport time\nfrom tictectoc import i, e, o\nfor i in range(10):\n i()\n time.sleep(1)\n e()\no() # print '[TTT:default] Elapsed time is 0:00:10'\n```\n\n\n6. decorator\n```\nimport time\nfrom tictectoc import ttt\n@ttt.dec('timer0')\ndef function(n=10):\n for i in range(n):\n time.sleep(1)\nfunction() # print '[TTT:timer0] Elapsed time is 0:00:10'\n```\n```\nimport time\nfrom tictectoc import dec\n@dec('timer0')\ndef function(n=1):\n for i in range(n):\n time.sleep(1)\n \nfunction() # print '[TTT:timer0] Elapsed time is 0:00:10'\n```\n\n7. (a) with statement\n\n```\nimport time\nfrom tictectoc import TicTecToc\nwith TicTecToc():\n for i in range(10):\n time.sleep(1)\n# print '[TTT::default] Elapsed time is 0:00:10'\n```\n\n```\nimport time\nfrom tictectoc import ttt\nwith ttt:\n for i in range(10):\n time.sleep(1)\n# print '[TTT::default] Elapsed time is 0:00:10'\n```\n\n7. (b) double with \n```\nimport time\nfrom tictectoc import TicTecToc\nwith TicTecToc('timer0'):\n with TicTecToc('timer1'):\n time.sleep(10)\n time.sleep(10)\n# print '[TTT::timer1] Elapsed time is 0:00:10'\n# print '[TTT::timer0] Elapsed time is 0:00:20'\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Tic Tec Toc timing for Python",
"version": "0.2.0",
"project_urls": {
"Homepage": "https://github.com/nemodleo/tictectoc"
},
"split_keywords": [
"tic",
"tec",
"toc",
"tictoc",
"tictectoc",
"time",
"timing"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "984ee7a0cb64142c242a5b4c75b1548b3f3276b199abebbd271e318832375b00",
"md5": "03760bd81879f4a28f6badf98e4b7b07",
"sha256": "3443de3867e0c4cc866f38381cd48c0a4d3d401009330f665c53a4c22b006e23"
},
"downloads": -1,
"filename": "tictectoc-0.2.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "03760bd81879f4a28f6badf98e4b7b07",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">= 3.6",
"size": 3728,
"upload_time": "2023-08-07T01:04:33",
"upload_time_iso_8601": "2023-08-07T01:04:33.661589Z",
"url": "https://files.pythonhosted.org/packages/98/4e/e7a0cb64142c242a5b4c75b1548b3f3276b199abebbd271e318832375b00/tictectoc-0.2.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-08-07 01:04:33",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "nemodleo",
"github_project": "tictectoc",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "tictectoc"
}