Skip to main content

Module with C functions. No precise purpose yet.

Project description

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

cpyquickhelper: python + C++ in different ways

Build status Build Status Windows 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 MIT License https://codecov.io/github/sdpython/cpyquickhelper/coverage.svg?branch=master GitHub Issues Notebook Coverage Downloads size Forks Stars

cpyquickhelper is a template to create a module with C functions in different ways. It implements function 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}

It also implements an event profiler: it logs the timestamp for every event such as functions call or returns, memory allocations.

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

Links:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cpyquickhelper-0.3.412.tar.gz (213.6 kB view hashes)

Uploaded Source

Built Distributions

cpyquickhelper-0.3.412-cp310-cp310-win_amd64.whl (811.8 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

cpyquickhelper-0.3.412-cp310-cp310-manylinux_2_24_x86_64.whl (10.2 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.24+ x86-64

cpyquickhelper-0.3.412-cp310-cp310-macosx_10_9_x86_64.whl (1.2 MB view hashes)

Uploaded CPython 3.10 macOS 10.9+ x86-64

cpyquickhelper-0.3.412-cp39-cp39-win_amd64.whl (802.8 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

cpyquickhelper-0.3.412-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (10.6 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

cpyquickhelper-0.3.412-cp39-cp39-macosx_10_9_x86_64.whl (1.4 MB view hashes)

Uploaded CPython 3.9 macOS 10.9+ x86-64

cpyquickhelper-0.3.412-cp38-cp38-win_amd64.whl (811.7 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

cpyquickhelper-0.3.412-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (10.6 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

cpyquickhelper-0.3.412-cp38-cp38-macosx_10_9_x86_64.whl (1.2 MB view hashes)

Uploaded CPython 3.8 macOS 10.9+ x86-64

cpyquickhelper-0.3.412-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (10.8 MB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

cpyquickhelper-0.3.412-cp37-cp37m-macosx_10_9_x86_64.whl (1.2 MB view hashes)

Uploaded CPython 3.7m macOS 10.9+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page