Skip to main content

带有 C 函数的模块。还没有确切的目的。

项目描述

https://github.com/sdpython/cpyquickhelper/blob/master/_doc/sphinxdoc/source/phdoc_static/project_ico.png?raw=true

cpyquickhelper:python + C++ 的不同方式

构建状态 构建状态窗口 https://circleci.com/gh/sdpython/cpyquickhelper/tree/master.svg?style=svg https://dev.azure.com/xavierdupre3/cpyquickhelper/_apis/build/status/sdpython.cpyquickhelper https://badge.fury.io/py/cpyquickhelper.svg 麻省理工学院许可证 https://codecov.io/github/sdpython/cpyquickhelper/coverage.svg?branch=master GitHub 问题 笔记本覆盖率 下载 尺寸 叉子 星星

cpyquickhelper是一个模板,用于以不同方式创建具有 C 函数的模块。它实现了函数 measure_time

from cpyquickhelper.numbers import measure_time
from math import cos

res = measure_time(lambda: cos(0.5))
print(res)
{'average': 3.909366205334663e-06, 'deviation': 6.238702219064397e-07,
 'min_exec': 3.635883331298828e-06, 'max_exec': 5.776062607765198e-06,
 'repeat': 10, 'number': 50, 'context_size': 240}

它还实现了一个事件分析器:它记录每个事件的时间戳,例如函数调用或返回、内存分配。

import io
import numpy
from cpyquickhelper.profiling import EventProfiler

def custom_array(N):
    a = numpy.zeros((N, N))
    a[:, 0] = 1
    a[0, :] = 1
    return a

ev = EventProfiler(impl='c')
ev.start()

custom_array(3)

ev.stop()

df = ev.retrieve_results()  # DataFrame
st = io.StringIO()
df.to_csv(st, index=False)
print(st.getvalue().replace("\r", ""))
time,value1,value2,event,name,mod,lineno,from_name,from_mod,from_line
822467345556400,0,0,return,_setup_profiler,cpyquickhelper/profiling/event_profiler.py,153,start,cpyquickhelper/profiling/event_profiler.py,126
822467345566700,0,0,c_call,_profiling_register_pyinstance,cpyquickhelper.profiling._event_profiler_c,109,_profiling_register_pyinstance,k.py,19
822467345569000,0,0,c_return,_profiling_register_pyinstance,cpyquickhelper.profiling._event_profiler_c,109,_profiling_register_pyinstance,k.py,19
822467345569700,0,0,return,start,cpyquickhelper/profiling/event_profiler.py,109,<module>,k.py,19
822467345575100,0,0,call,custom_array,k.py,5,<module>,k.py,19
822467345579600,0,0,c_call,zeros,numpy,5,zeros,k.py,19
822467345584300,2698130437280,32,malloc,start,cpyquickhelper/profiling/event_profiler.py,109,<module>,k.py,19
822467345590500,0,0,c_return,zeros,numpy,5,zeros,k.py,19
822467345598200,0,0,free,start,cpyquickhelper/profiling/event_profiler.py,109,<module>,k.py,19
822467345600400,0,0,free,start,cpyquickhelper/profiling/event_profiler.py,109,<module>,k.py,19
822467345600900,0,0,return,ndarray,numpy,5,ndarray,k.py,19
822467345603200,0,0,call,stop,cpyquickhelper/profiling/event_profiler.py,128,<module>,k.py,19
822467345604900,0,0,call,_restore_profiler,cpyquickhelper/profiling/event_profiler.py,168,stop,cpyquickhelper/profiling/event_profiler.py,151
822467345605600,0,0,c_call,setprofile,sys,168,setprofile,cpyquickhelper/profiling/event_profiler.py,151

链接:

项目详情


下载文件

下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。

源分布

cpyquickhelper-0.3.412.tar.gz (213.6 kB 查看哈希

已上传 source

内置发行版

cpyquickhelper-0.3.412-cp310-cp310-win_amd64.whl (811.8 kB 查看哈希

已上传 cp310

cpyquickhelper-0.3.412-cp310-cp310-manylinux_2_24_x86_64.whl (10.2 MB 查看哈希

已上传 cp310

cpyquickhelper-0.3.412-cp310-cp310-macosx_10_9_x86_64.whl (1.2 MB 查看哈希

已上传 cp310

cpyquickhelper-0.3.412-cp39-cp39-win_amd64.whl (802.8 kB 查看哈希

已上传 cp39

cpyquickhelper-0.3.412-cp39-cp39-macosx_10_9_x86_64.whl (1.4 MB 查看哈希

已上传 cp39

cpyquickhelper-0.3.412-cp38-cp38-win_amd64.whl (811.7 kB 查看哈希

已上传 cp38

cpyquickhelper-0.3.412-cp38-cp38-macosx_10_9_x86_64.whl (1.2 MB 查看哈希

已上传 cp38

cpyquickhelper-0.3.412-cp37-cp37m-macosx_10_9_x86_64.whl (1.2 MB 查看哈希

已上传 cp37