Created
January 3, 2019 06:59
-
-
Save venkataanil/c9f160f095ed6faaf57c446e9b339aa9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[root@gprfc049 ~]# pyvenv-3.6 3.6 | |
WARNING: the pyenv script is deprecated in favour of `python3.6 -m venv` | |
[root@gprfc049 ~]# source 3.6/bin/activate | |
(3.6) [root@gprfc049 ~]# pip install greenlet | |
Collecting greenlet | |
Using cached https://files.pythonhosted.org/packages/bf/45/142141aa47e01a5779f0fa5a53b81f8379ce8f2b1cd13df7d2f1d751ae42/greenlet-0.4.15-cp36-cp36m-manylinux1_x86_64.whl | |
Installing collected packages: greenlet | |
Successfully installed greenlet-0.4.15 | |
You are using pip version 10.0.1, however version 18.1 is available. | |
You should consider upgrading via the 'pip install --upgrade pip' command. | |
(3.6) [root@gprfc049 ~]# pip install yappi | |
Collecting yappi | |
Using cached https://files.pythonhosted.org/packages/35/43/489bf1dd0923c16b4abe09271da979ca0576662d02ba59f26cfb54e93be1/yappi-0.98.tar.gz | |
Installing collected packages: yappi | |
Running setup.py install for yappi ... done | |
Successfully installed yappi-0.98 | |
You are using pip version 10.0.1, however version 18.1 is available. | |
You should consider upgrading via the 'pip install --upgrade pip' command. | |
(3.6) [root@gprfc049 ~]# python -V | |
Python 3.6.6 | |
(3.6) [root@gprfc049 ~]# cat testyappi.py | |
import greenlet | |
import yappi | |
def _trace(trace_file=None): | |
if not trace_file: | |
yappi.set_clock_type('cpu') | |
# We need to set context to greenlet to profile greenlets | |
# https://bitbucket.org/sumerc/yappi/pull-requests/3 | |
yappi.set_context_id_callback( | |
lambda: id(greenlet.getcurrent())) | |
yappi.set_context_name_callback( | |
lambda: greenlet.getcurrent().__class__.__name__) | |
yappi.start() | |
else: | |
yappi.stop() | |
stats = yappi.get_func_stats() | |
try: | |
stats.print_all() | |
#stats.save(trace_file, "pstat") | |
except Exception as e: | |
print("Error while saving the trace stats ", str(e)) | |
yappi.clear_stats() | |
def fun1(i): | |
print(i) | |
_trace() | |
for i in range(1,10): | |
fun1(i) | |
_trace("/tmp/trace3") | |
(3.6) [root@gprfc049 ~]# | |
(3.6) [root@gprfc049 ~]# python testyappi.py | |
1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
Clock type: CPU | |
Ordered by: totaltime, desc | |
name ncall tsub ttot tavg | |
testyappi.py:26 fun1 9 0.000026 0.000118 0.000013 | |
testyappi.py:5 _trace 1 0.000000 0.000000 0.000000 | |
(3.6) [root@gprfc049 ~]# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment