mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-19 19:10:17 +00:00
...
This commit is contained in:
parent
5ad606859f
commit
19563e33d2
@ -1,41 +0,0 @@
|
||||
---
|
||||
icon: package
|
||||
label: line_profiler
|
||||
---
|
||||
|
||||
!!!
|
||||
This module is optional. Set `PK_ENABLE_PROFILER` to `1` to enable it.
|
||||
!!!
|
||||
|
||||
## Example
|
||||
|
||||
```python
|
||||
from line_profiler import LineProfiler
|
||||
|
||||
def my_func():
|
||||
a = 0
|
||||
for i in range(1000000):
|
||||
a += i
|
||||
return a
|
||||
|
||||
lp = LineProfiler()
|
||||
|
||||
lp.add_function(my_func)
|
||||
|
||||
lp.runcall(my_func)
|
||||
|
||||
lp.print_stats()
|
||||
```
|
||||
|
||||
```txt
|
||||
Total time: 0.243s
|
||||
File: 84_line_profiler.py
|
||||
Function: my_func at line 3
|
||||
Line # Hits Time Per Hit % Time Line Contents
|
||||
==============================================================
|
||||
3 def my_func():
|
||||
4 1 0 0 0.0 a = 0
|
||||
5 1000001 69 0 28.4 for i in range(1000000):
|
||||
6 1000001 174 0 71.6 a += i
|
||||
7 1 0 0 0.0 return a
|
||||
```
|
@ -13,11 +13,6 @@
|
||||
#define PK_ENABLE_OS 1
|
||||
#endif
|
||||
|
||||
// Enable `line_profiler` module and `breakpoint()` function
|
||||
#ifndef PK_ENABLE_PROFILER // can be overridden by cmake
|
||||
#define PK_ENABLE_PROFILER 0
|
||||
#endif
|
||||
|
||||
// GC min threshold
|
||||
#ifndef PK_GC_MIN_THRESHOLD // can be overridden by cmake
|
||||
#define PK_GC_MIN_THRESHOLD 16384
|
||||
@ -45,10 +40,4 @@
|
||||
#define PK_PLATFORM_SEP '\\'
|
||||
#else
|
||||
#define PK_PLATFORM_SEP '/'
|
||||
#endif
|
||||
|
||||
#ifdef NDEBUG
|
||||
#define PK_DEBUG 0
|
||||
#else
|
||||
#define PK_DEBUG 1
|
||||
#endif
|
@ -548,7 +548,7 @@ PK_EXPORT bool py_isidentical(py_Ref, py_Ref);
|
||||
/// The stack remains unchanged after the operation.
|
||||
PK_EXPORT bool py_call(py_Ref f, int argc, py_Ref argv) PY_RAISE PY_RETURN;
|
||||
|
||||
#if PK_DEBUG
|
||||
#ifndef NDEBUG
|
||||
/// Call a `py_CFunction` in a safe way.
|
||||
/// This function does extra checks to help you debug `py_CFunction`.
|
||||
PK_EXPORT bool py_callcfunc(py_CFunction f, int argc, py_Ref argv) PY_RAISE PY_RETURN;
|
||||
|
@ -87,7 +87,7 @@ FrameResult VM__run_top_frame(VM* self) {
|
||||
__NEXT_STEP:
|
||||
byte = *frame->ip;
|
||||
|
||||
#if PK_DEBUG
|
||||
#ifndef NDEBUG
|
||||
pk_print_stack(self, frame, byte);
|
||||
// assert(!py_checkexc(true));
|
||||
#endif
|
||||
|
@ -118,7 +118,7 @@ bool py_call(py_Ref f, int argc, py_Ref argv) {
|
||||
}
|
||||
}
|
||||
|
||||
#if PK_DEBUG
|
||||
#ifndef NDEBUG
|
||||
bool py_callcfunc(py_CFunction f, int argc, py_Ref argv) {
|
||||
py_StackRef p0 = py_peek(0);
|
||||
py_newnil(py_retval());
|
||||
|
@ -43,7 +43,7 @@ int main(int argc, char** argv) {
|
||||
if(argc == 1) {
|
||||
printf("pocketpy " PK_VERSION " (" __DATE__ ", " __TIME__ ") ");
|
||||
printf("[%d bit] on %s", (int)(sizeof(void*) * 8), PY_SYS_PLATFORM_STRING);
|
||||
#if PK_DEBUG
|
||||
#ifndef NDEBUG
|
||||
printf(" (DEBUG)");
|
||||
#endif
|
||||
printf("\n");
|
||||
|
Loading…
x
Reference in New Issue
Block a user