Index: TODO =================================================================== diff -u -r57570354bfebc1bc24f1ba3d7976c44b2c2bd3e9 -rbb0d12c63024e25ca81a370eb934dbbe2b7a10fd --- TODO (.../TODO) (revision 57570354bfebc1bc24f1ba3d7976c44b2c2bd3e9) +++ TODO (.../TODO) (revision bb0d12c63024e25ca81a370eb934dbbe2b7a10fd) @@ -2329,9 +2329,16 @@ class for relation type "class" - updated documentation +- reanimated NSF_PROFILE (when activated, needs more stack and slows execution slightly down) TODO: +- NSF_PROFILE + * provide an interface to clear and to output PROFILE data. + * output should provide a cutoff value. + * most probably it has memory leak in multithreaded apps, + since it was originally just developed for simple testing + - document value added replacements of Tcl functions - object parameter type forward: Index: generic/nsf.c =================================================================== diff -u -r4271f1017962a2fc3613d6be3f31f01ef2f63d82 -rbb0d12c63024e25ca81a370eb934dbbe2b7a10fd --- generic/nsf.c (.../nsf.c) (revision 4271f1017962a2fc3613d6be3f31f01ef2f63d82) +++ generic/nsf.c (.../nsf.c) (revision bb0d12c63024e25ca81a370eb934dbbe2b7a10fd) @@ -243,7 +243,7 @@ static NsfClass *DefaultSuperClass(Tcl_Interp *interp, NsfClass *cl, NsfClass *mcl, int isMeta); /* prototypes for call stack specific calls */ -NSF_INLINE static void CscInit(NsfCallStackContent *cscPtr, NsfObject *object, NsfClass *cl, +NSF_INLINE static void CscInit_(NsfCallStackContent *cscPtr, NsfObject *object, NsfClass *cl, Tcl_Command cmd, int frameType, int flags); NSF_INLINE static void CscFinish_(Tcl_Interp *interp, NsfCallStackContent *cscPtr); NSF_INLINE static void CallStackDoDestroy(Tcl_Interp *interp, NsfObject *object); @@ -7698,22 +7698,6 @@ return result; } -#if defined(NSF_PROFILE) -/* TODO: should be adjusted to MethodDispatchCsc() */ -static int -MethodDispatch(ClientData clientData, Tcl_Interp *interp, - int objc, Tcl_Obj *CONST objv[], Tcl_Command cmd, NsfObject *object, NsfClass *cl, - CONST char *methodName, int frameType) { - struct timeval trt; - long int startUsec = (gettimeofday(&trt, NULL), trt.tv_usec), startSec = trt.tv_sec; - - result = __MethodDispatch__(clientData, interp, objc, objv, cmd, object, cl, methodName, frameType); - NsfProfileEvaluateData(interp, startSec, startUsec, object, cl, methodName); - return result; -} -# define MethodDispatch __MethodDispatch__ -#endif - /* *---------------------------------------------------------------------- * MethodDispatchCsc -- @@ -7973,7 +7957,7 @@ * cp == NULL && !(Tcl_Command_flags(cmd) & NSF_CMD_NONLEAF_METHOD) * TODO: We could pass cmd==NULL, but is this worth it? */ - CscInit(cscPtr, object, cl, cmd, frameType, flags); + CscInit(cscPtr, object, cl, cmd, frameType, flags, methodName); result = MethodDispatchCsc(clientData, interp, objc, objv, cscPtr, methodName); @@ -8213,7 +8197,7 @@ /*fprintf(stderr, "mixinsearch returned an error for %p %s.%s\n", object, ObjectName(object),methodName);*/ cscPtr = CscAlloc(interp, &csc, NULL); - CscInit(cscPtr, object, cl, NULL, frameType, flags); + CscInit(cscPtr, object, cl, NULL, frameType, flags, methodName); goto exit_object_dispatch; } if (cmd) { @@ -8300,7 +8284,7 @@ * We found the method to dispatch. */ cscPtr = CscAlloc(interp, &csc, cmd); - CscInit(cscPtr, object, cl, cmd, frameType, flags); + CscInit(cscPtr, object, cl, cmd, frameType, flags, methodName); if ((cscPtr->frameType == NSF_CSC_TYPE_ACTIVE_FILTER)) { /* run filters not NRE enabled */ @@ -8325,7 +8309,7 @@ * The method to be dispatched is unknown */ cscPtr = CscAlloc(interp, &csc, cmd); - CscInit(cscPtr, object, cl, cmd, frameType, flags); + CscInit(cscPtr, object, cl, cmd, frameType, flags, methodName); cscPtr->flags |= NSF_CSC_METHOD_IS_UNKNOWN; if ((flags & NSF_CM_NO_UNKNOWN)) { @@ -16739,7 +16723,7 @@ Tcl_Interp_varFramePtr(interp) = varFramePtr->callerPtr; cscPtr->flags = 0; - CscInit(cscPtr, object, NULL /*cl*/, NULL /*cmd*/, NSF_CSC_TYPE_PLAIN, 0); + CscInit(cscPtr, object, NULL /*cl*/, NULL /*cmd*/, NSF_CSC_TYPE_PLAIN, 0, "configure"); Nsf_PushFrameCsc(interp, cscPtr, framePtr2); if (paramPtr->flags & NSF_ARG_INITCMD) { Index: generic/nsf.h =================================================================== diff -u -re0d21a9856a40f8ea20454452aae3295fe572011 -rbb0d12c63024e25ca81a370eb934dbbe2b7a10fd --- generic/nsf.h (.../nsf.h) (revision e0d21a9856a40f8ea20454452aae3295fe572011) +++ generic/nsf.h (.../nsf.h) (revision bb0d12c63024e25ca81a370eb934dbbe2b7a10fd) @@ -71,7 +71,7 @@ /* activate/deacticate profiling information at the end of running the program -#define NSF_PROFILE +#define NSF_PROFILE 1 */ /* are we developing? @@ -153,6 +153,14 @@ CscFinish_(interp, cscPtr) #endif +#if defined(NSF_PROFILE) +# define CscInit(cscPtr, object, cl, cmd, frametype, flags, method) \ + CscInit_(cscPtr, object, cl, cmd, frametype, flags); cscPtr->methodName = (method); +#else +# define CscInit(cscPtr, object, cl, cmd, frametype, flags, methodName) \ + CscInit_(cscPtr, object, cl, cmd, frametype, flags) +#endif + #if !defined(CHECK_ACTIVATION_COUNTS) # define CscListAdd(interp, cscPtr) # define CscListRemove(interp, cscPtr) Index: generic/nsfInt.h =================================================================== diff -u -rfc36bf33edd6f5b3f273cb2abdcb30f2ececdff4 -rbb0d12c63024e25ca81a370eb934dbbe2b7a10fd --- generic/nsfInt.h (.../nsfInt.h) (revision fc36bf33edd6f5b3f273cb2abdcb30f2ececdff4) +++ generic/nsfInt.h (.../nsfInt.h) (revision bb0d12c63024e25ca81a370eb934dbbe2b7a10fd) @@ -651,6 +651,11 @@ int objc; unsigned short frameType; unsigned short flags; +#if defined(NSF_PROFILE) + long int startUsec; + long int startSec; + CONST char *methodName; +#endif } NsfCallStackContent; #define NSF_CSC_TYPE_PLAIN 0 @@ -777,8 +782,8 @@ NsfProfileFillTable(Tcl_HashTable *table, Tcl_DString *key, double totalMicroSec); extern void -NsfProfileEvaluateData(Tcl_Interp *interp, long int startSec, long int startUsec, - NsfObject *obj, NsfClass *cl, char *methodName); +NsfProfileEvaluateData(Tcl_Interp* interp, NsfCallStackContent *cscPtr); + extern void NsfProfilePrintTable(Tcl_HashTable *table); Index: generic/nsfProfile.c =================================================================== diff -u -r821c01bd241c51be4fa0931d423d8f8658606ee1 -rbb0d12c63024e25ca81a370eb934dbbe2b7a10fd --- generic/nsfProfile.c (.../nsfProfile.c) (revision 821c01bd241c51be4fa0931d423d8f8658606ee1) +++ generic/nsfProfile.c (.../nsfProfile.c) (revision bb0d12c63024e25ca81a370eb934dbbe2b7a10fd) @@ -1,13 +1,13 @@ /* -*- Mode: c++ -*- * - * Extended Object Tcl (XOTcl) + * Next Scripting Framework * * Copyright (C) 1999-2010 Gustaf Neumann, Uwe Zdun * * * nsfProfile.c -- * - * Profiling information printout for XOTcl + * Profiling information printout for Next Scripting Framework * * For profiling infos NSF_PROFILE (nsf.h) flag must be activated * @@ -46,13 +46,16 @@ } void -NsfProfileEvaluateData(Tcl_Interp* interp, long int startSec, long int startUsec, - NsfObject* obj, NsfClass *cl, char *methodName) { +NsfProfileEvaluateData(Tcl_Interp* interp, NsfCallStackContent *cscPtr) { double totalMicroSec; - struct timeval trt; + NsfObject* obj = cscPtr->self; + NsfClass *cl = cscPtr->cl; + long int startSec = cscPtr->startSec; + long int startUsec = cscPtr->startUsec; + CONST char *methodName = cscPtr->methodName; Tcl_DString objectKey, methodKey; - NsfProfile* profile = &RUNTIME_STATE(interp)->profile; + struct timeval trt; gettimeofday(&trt, NULL); @@ -61,7 +64,7 @@ profile->overallTime += totalMicroSec; - if (obj->teardown == 0 || !obj->id || obj->destroyCalled) { + if (obj->teardown == 0 || !obj->id) { return; } Tcl_DStringInit(&objectKey); @@ -71,15 +74,16 @@ Tcl_DStringAppend(&methodKey, cl ? ObjStr(cl->object.cmdName) : ObjStr(obj->cmdName), -1); Tcl_DStringAppend(&methodKey, "->", 2); Tcl_DStringAppend(&methodKey, methodName, -1); - if (cl) - Tcl_DStringAppend(&methodKey, " (instproc)", 11); - else - Tcl_DStringAppend(&methodKey, " (proc)", 7); + if (cl) { + Tcl_DStringAppend(&methodKey, " method", 7); + } else { + Tcl_DStringAppend(&methodKey, " object method", 14); + } NsfProfileFillTable(&profile->objectData, &objectKey, totalMicroSec); NsfProfileFillTable(&profile->methodData, &methodKey, totalMicroSec); Tcl_DStringFree(&objectKey); - Tcl_StringFree(&methodKey); + Tcl_DStringFree(&methodKey); } void Index: generic/nsfStack.c =================================================================== diff -u -rf7e7dd532f08b253e4b81e73074e216674685d60 -rbb0d12c63024e25ca81a370eb934dbbe2b7a10fd --- generic/nsfStack.c (.../nsfStack.c) (revision f7e7dd532f08b253e4b81e73074e216674685d60) +++ generic/nsfStack.c (.../nsfStack.c) (revision bb0d12c63024e25ca81a370eb934dbbe2b7a10fd) @@ -802,10 +802,20 @@ *---------------------------------------------------------------------- */ NSF_INLINE static void -CscInit(/*@notnull@*/ NsfCallStackContent *cscPtr, NsfObject *object, NsfClass *cl, +CscInit_(/*@notnull@*/ NsfCallStackContent *cscPtr, NsfObject *object, NsfClass *cl, Tcl_Command cmd, int frameType, int flags) { +#if defined(NSF_PROFILE) + struct timeval trt; +#endif assert(cscPtr); + +#if defined(NSF_PROFILE) + gettimeofday(&trt, NULL); + + cscPtr->startUsec = trt.tv_usec; + cscPtr->startSec = trt.tv_sec; +#endif /* * When cmd is provided, the call is not an unknown, the method @@ -875,6 +885,10 @@ assert(cscPtr); assert(cscPtr->self); +#if defined(NSF_PROFILE) + NsfProfileEvaluateData(interp, cscPtr); +#endif + object = cscPtr->self; flags = cscPtr->flags;