@@ -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,56 @@ 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
+ cls: defining_class
570
+
571
+ list of profiler_entry objects.
572
+
573
+ getstats() -> list of profiler_entry objects
574
+
575
+ Return all information collected by the profiler.
576
+ Each profiler_entry is a tuple-like object with the
577
+ following attributes:
578
+
579
+ code code object
580
+ callcount how many times this was called
581
+ reccallcount how many times called recursively
582
+ totaltime total time in this entry
583
+ inlinetime inline time in this entry (not in subcalls)
584
+ calls details of the calls
585
+
586
+ The calls attribute is either None or a list of
587
+ profiler_subentry objects:
588
+
589
+ code called code object
590
+ callcount how many times this is called
591
+ reccallcount how many times this is called recursively
592
+ totaltime total time spent in this call
593
+ inlinetime inline time (not in further subcalls)
594
+ [clinic start generated code]*/
595
+
596
+ static PyObject *
597
+ _lsprof_Profiler_getstats_impl (ProfilerObject * self , PyTypeObject * cls )
598
+ /*[clinic end generated code: output=1806ef720019ee03 input=445e193ef4522902]*/
585
599
{
586
600
statscollector_t collect ;
587
- if (pending_exception (pObj )) {
601
+ if (pending_exception (self )) {
588
602
return NULL ;
589
603
}
590
- if (!pObj -> externalTimer || pObj -> externalTimerUnit == 0.0 ) {
604
+ if (!self -> externalTimer || self -> externalTimerUnit == 0.0 ) {
591
605
_PyTime_t onesec = _PyTime_FromSeconds (1 );
592
606
collect .factor = (double )1 / onesec ;
593
607
}
594
608
else {
595
- collect .factor = pObj -> externalTimerUnit ;
609
+ collect .factor = self -> externalTimerUnit ;
596
610
}
597
611
598
612
collect .list = PyList_New (0 );
599
613
if (collect .list == NULL )
600
614
return NULL ;
601
- if (RotatingTree_Enum (pObj -> profilerEntries , statsForEntry , & collect )
615
+ if (RotatingTree_Enum (self -> profilerEntries , statsForEntry , & collect )
602
616
!= 0 ) {
603
617
Py_DECREF (collect .list );
604
618
return NULL ;
@@ -750,8 +764,7 @@ profiler_init(ProfilerObject *pObj, PyObject *args, PyObject *kw)
750
764
}
751
765
752
766
static PyMethodDef profiler_methods [] = {
753
- {"getstats" , (PyCFunction )profiler_getstats ,
754
- METH_NOARGS , getstats_doc },
767
+ _LSPROF_PROFILER_GETSTATS_METHODDEF
755
768
{"enable" , (PyCFunction )(void (* )(void ))profiler_enable ,
756
769
METH_VARARGS | METH_KEYWORDS , enable_doc },
757
770
{"disable" , (PyCFunction )profiler_disable ,
0 commit comments