@@ -50,8 +50,15 @@ typedef struct {
50
50
#define POF_BUILTINS 0x004
51
51
#define POF_NOMEMORY 0x100
52
52
53
+ /*[clinic input]
54
+ module _lsprof
55
+ class _lsprof.Profiler "ProfilerObject *" "&ProfilerType"
56
+ [clinic start generated code]*/
57
+ /*[clinic end generated code: output=da39a3ee5e6b4b0d input=e349ac952152f336]*/
53
58
static PyTypeObject PyProfiler_Type ;
54
59
60
+ #include "clinic/_lsprof.c.h"
61
+
55
62
#define PyProfiler_Check (op ) PyObject_TypeCheck(op, &PyProfiler_Type)
56
63
#define PyProfiler_CheckExact (op ) Py_IS_TYPE(op, &PyProfiler_Type)
57
64
@@ -556,49 +563,54 @@ static int statsForEntry(rotating_node_t *node, void *arg)
556
563
return err ;
557
564
}
558
565
559
- PyDoc_STRVAR (getstats_doc , "\
560
- getstats() -> list of profiler_entry objects\n\
561
- \n\
562
- Return all information collected by the profiler.\n\
563
- Each profiler_entry is a tuple-like object with the\n\
564
- following attributes:\n\
565
- \n\
566
- code code object\n\
567
- callcount how many times this was called\n\
568
- reccallcount how many times called recursively\n\
569
- totaltime total time in this entry\n\
570
- inlinetime inline time in this entry (not in subcalls)\n\
571
- calls details of the calls\n\
572
- \n\
573
- The calls attribute is either None or a list of\n\
574
- profiler_subentry objects:\n\
575
- \n\
576
- code called code object\n\
577
- callcount how many times this is called\n\
578
- reccallcount how many times this is called recursively\n\
579
- totaltime total time spent in this call\n\
580
- inlinetime inline time (not in further subcalls)\n\
581
- " );
566
+ /*[clinic input]
567
+ _lsprof.Profiler.getstats
582
568
583
- static PyObject *
584
- profiler_getstats (ProfilerObject * pObj , PyObject * noarg )
569
+ list of profiler_entry objects.
570
+
571
+ getstats() -> list of profiler_entry objects
572
+
573
+ Return all information collected by the profiler.
574
+ Each profiler_entry is a tuple-like object with the
575
+ following attributes:
576
+
577
+ code code object
578
+ callcount how many times this was called
579
+ reccallcount how many times called recursively
580
+ totaltime total time in this entry
581
+ inlinetime inline time in this entry (not in subcalls)
582
+ calls details of the calls
583
+
584
+ The calls attribute is either None or a list of
585
+ profiler_subentry objects:
586
+
587
+ code called code object
588
+ callcount how many times this is called
589
+ reccallcount how many times this is called recursively
590
+ totaltime total time spent in this call
591
+ inlinetime inline time (not in further subcalls)
592
+ [clinic start generated code]*/
593
+
594
+ static PyObject *
595
+ _lsprof_Profiler_getstats_impl (ProfilerObject * self )
596
+ /*[clinic end generated code: output=9461b451e9ef0f24 input=ade04fa384ce450a]*/
585
597
{
586
598
statscollector_t collect ;
587
- if (pending_exception (pObj )) {
599
+ if (pending_exception (self )) {
588
600
return NULL ;
589
601
}
590
- if (!pObj -> externalTimer || pObj -> externalTimerUnit == 0.0 ) {
602
+ if (!self -> externalTimer || self -> externalTimerUnit == 0.0 ) {
591
603
_PyTime_t onesec = _PyTime_FromSeconds (1 );
592
604
collect .factor = (double )1 / onesec ;
593
605
}
594
606
else {
595
- collect .factor = pObj -> externalTimerUnit ;
607
+ collect .factor = self -> externalTimerUnit ;
596
608
}
597
609
598
610
collect .list = PyList_New (0 );
599
611
if (collect .list == NULL )
600
612
return NULL ;
601
- if (RotatingTree_Enum (pObj -> profilerEntries , statsForEntry , & collect )
613
+ if (RotatingTree_Enum (self -> profilerEntries , statsForEntry , & collect )
602
614
!= 0 ) {
603
615
Py_DECREF (collect .list );
604
616
return NULL ;
@@ -750,8 +762,7 @@ profiler_init(ProfilerObject *pObj, PyObject *args, PyObject *kw)
750
762
}
751
763
752
764
static PyMethodDef profiler_methods [] = {
753
- {"getstats" , (PyCFunction )profiler_getstats ,
754
- METH_NOARGS , getstats_doc },
765
+ _LSPROF_PROFILER_GETSTATS_METHODDEF
755
766
{"enable" , (PyCFunction )(void (* )(void ))profiler_enable ,
756
767
METH_VARARGS | METH_KEYWORDS , enable_doc },
757
768
{"disable" , (PyCFunction )profiler_disable ,
0 commit comments