00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #define _PROFLFUN_SOURCE_
00035
00036 #include "setup.h"
00037
00038 #if PROFILING_FUNCTIONS
00039
00040 #include "argacces.h"
00041 #include "classcom.h"
00042 #include "dffnxfun.h"
00043 #include "envrnmnt.h"
00044 #include "extnfunc.h"
00045 #include "genrccom.h"
00046 #include "genrcfun.h"
00047 #include "memalloc.h"
00048 #include "msgcom.h"
00049 #include "router.h"
00050 #include "sysdep.h"
00051
00052 #include "proflfun.h"
00053
00054 #include <string.h>
00055
00056 #define NO_PROFILE 0
00057 #define USER_FUNCTIONS 1
00058 #define CONSTRUCTS_CODE 2
00059
00060 #define OUTPUT_STRING "%-40s %7ld %15.6f %8.2f%% %15.6f %8.2f%%\n"
00061
00062
00063
00064
00065
00066 static intBool OutputProfileInfo(void *,char *,struct constructProfileInfo *,
00067 char *,char *,char *,char **);
00068 static void OutputUserFunctionsInfo(void *);
00069 static void OutputConstructsCodeInfo(void *);
00070 #if (! RUN_TIME)
00071 static void ProfileClearFunction(void *);
00072 #endif
00073
00074
00075
00076
00077
00078 globle void ConstructProfilingFunctionDefinitions(
00079 void *theEnv)
00080 {
00081 struct userDataRecord profileDataInfo = { 0, CreateProfileData, DeleteProfileData };
00082
00083 AllocateEnvironmentData(theEnv,PROFLFUN_DATA,sizeof(struct profileFunctionData),NULL);
00084
00085 memcpy(&ProfileFunctionData(theEnv)->ProfileDataInfo,&profileDataInfo,sizeof(struct userDataRecord));
00086
00087 ProfileFunctionData(theEnv)->LastProfileInfo = NO_PROFILE;
00088 ProfileFunctionData(theEnv)->PercentThreshold = 0.0;
00089 ProfileFunctionData(theEnv)->OutputString = OUTPUT_STRING;
00090
00091 #if ! RUN_TIME
00092 EnvDefineFunction2(theEnv,"profile",'v', PTIEF ProfileCommand,"ProfileCommand","11w");
00093 EnvDefineFunction2(theEnv,"profile-info",'v', PTIEF ProfileInfoCommand,"ProfileInfoCommand","01w");
00094 EnvDefineFunction2(theEnv,"profile-reset",'v', PTIEF ProfileResetCommand,"ProfileResetCommand","00");
00095
00096 EnvDefineFunction2(theEnv,"set-profile-percent-threshold",'d',
00097 PTIEF SetProfilePercentThresholdCommand,
00098 "SetProfilePercentThresholdCommand","11n");
00099 EnvDefineFunction2(theEnv,"get-profile-percent-threshold",'d',
00100 PTIEF GetProfilePercentThresholdCommand,
00101 "GetProfilePercentThresholdCommand","00");
00102
00103 ProfileFunctionData(theEnv)->ProfileDataID = InstallUserDataRecord(theEnv,&ProfileFunctionData(theEnv)->ProfileDataInfo);
00104
00105 EnvAddClearFunction(theEnv,"profile",ProfileClearFunction,0);
00106 #endif
00107 }
00108
00109
00110
00111
00112
00113 globle void *CreateProfileData(
00114 void *theEnv)
00115 {
00116 struct constructProfileInfo *theInfo;
00117
00118 theInfo = (struct constructProfileInfo *)
00119 genalloc(theEnv,sizeof(struct constructProfileInfo));
00120
00121 theInfo->numberOfEntries = 0;
00122 theInfo->childCall = FALSE;
00123 theInfo->startTime = 0.0;
00124 theInfo->totalSelfTime = 0.0;
00125 theInfo->totalWithChildrenTime = 0.0;
00126
00127 return(theInfo);
00128 }
00129
00130
00131
00132
00133 globle void DeleteProfileData(
00134 void *theEnv,
00135 void *theData)
00136 {
00137 genfree(theEnv,theData,sizeof(struct constructProfileInfo));
00138 }
00139
00140
00141
00142
00143
00144 globle void ProfileCommand(
00145 void *theEnv)
00146 {
00147 char *argument;
00148 DATA_OBJECT theValue;
00149
00150 if (EnvArgCountCheck(theEnv,"profile",EXACTLY,1) == -1) return;
00151 if (EnvArgTypeCheck(theEnv,"profile",1,SYMBOL,&theValue) == FALSE) return;
00152
00153 argument = DOToString(theValue);
00154
00155 if (! Profile(theEnv,argument))
00156 {
00157 ExpectedTypeError1(theEnv,"profile",1,"symbol with value constructs, user-functions, or off");
00158 return;
00159 }
00160
00161 return;
00162 }
00163
00164
00165
00166
00167
00168 globle intBool Profile(
00169 void *theEnv,
00170 char *argument)
00171 {
00172
00173
00174
00175
00176
00177
00178
00179
00180 if (strcmp(argument,"user-functions") == 0)
00181 {
00182 ProfileFunctionData(theEnv)->ProfileStartTime = gentime();
00183 ProfileFunctionData(theEnv)->ProfileUserFunctions = TRUE;
00184 ProfileFunctionData(theEnv)->ProfileConstructs = FALSE;
00185 ProfileFunctionData(theEnv)->LastProfileInfo = USER_FUNCTIONS;
00186 }
00187
00188 else if (strcmp(argument,"constructs") == 0)
00189 {
00190 ProfileFunctionData(theEnv)->ProfileStartTime = gentime();
00191 ProfileFunctionData(theEnv)->ProfileUserFunctions = FALSE;
00192 ProfileFunctionData(theEnv)->ProfileConstructs = TRUE;
00193 ProfileFunctionData(theEnv)->LastProfileInfo = CONSTRUCTS_CODE;
00194 }
00195
00196
00197
00198
00199
00200
00201 else if (strcmp(argument,"off") == 0)
00202 {
00203 ProfileFunctionData(theEnv)->ProfileEndTime = gentime();
00204 ProfileFunctionData(theEnv)->ProfileTotalTime += (ProfileFunctionData(theEnv)->ProfileEndTime - ProfileFunctionData(theEnv)->ProfileStartTime);
00205 ProfileFunctionData(theEnv)->ProfileUserFunctions = FALSE;
00206 ProfileFunctionData(theEnv)->ProfileConstructs = FALSE;
00207 }
00208
00209
00210
00211
00212
00213
00214 else
00215 { return(FALSE); }
00216
00217 return(TRUE);
00218 }
00219
00220
00221
00222
00223
00224 globle void ProfileInfoCommand(
00225 void *theEnv)
00226 {
00227 int argCount;
00228 DATA_OBJECT theValue;
00229 char buffer[512];
00230
00231
00232
00233
00234
00235
00236 if ((argCount = EnvArgCountCheck(theEnv,"profile",NO_MORE_THAN,1)) == -1) return;
00237
00238
00239
00240
00241
00242
00243 if (argCount == 1)
00244 {
00245 if (EnvArgTypeCheck(theEnv,"profile",1,SYMBOL,&theValue) == FALSE) return;
00246 }
00247
00248
00249
00250
00251
00252
00253 if (ProfileFunctionData(theEnv)->ProfileUserFunctions || ProfileFunctionData(theEnv)->ProfileConstructs)
00254 {
00255 ProfileFunctionData(theEnv)->ProfileEndTime = gentime();
00256 ProfileFunctionData(theEnv)->ProfileTotalTime += (ProfileFunctionData(theEnv)->ProfileEndTime - ProfileFunctionData(theEnv)->ProfileStartTime);
00257 }
00258
00259
00260
00261
00262
00263 if (ProfileFunctionData(theEnv)->LastProfileInfo != NO_PROFILE)
00264 {
00265 gensprintf(buffer,"Profile elapsed time = %g seconds\n",
00266 ProfileFunctionData(theEnv)->ProfileTotalTime);
00267 EnvPrintRouter(theEnv,WDISPLAY,buffer);
00268
00269 if (ProfileFunctionData(theEnv)->LastProfileInfo == USER_FUNCTIONS)
00270 { EnvPrintRouter(theEnv,WDISPLAY,"Function Name "); }
00271 else if (ProfileFunctionData(theEnv)->LastProfileInfo == CONSTRUCTS_CODE)
00272 { EnvPrintRouter(theEnv,WDISPLAY,"Construct Name "); }
00273
00274 EnvPrintRouter(theEnv,WDISPLAY,"Entries Time % Time+Kids %+Kids\n");
00275
00276 if (ProfileFunctionData(theEnv)->LastProfileInfo == USER_FUNCTIONS)
00277 { EnvPrintRouter(theEnv,WDISPLAY,"------------- "); }
00278 else if (ProfileFunctionData(theEnv)->LastProfileInfo == CONSTRUCTS_CODE)
00279 { EnvPrintRouter(theEnv,WDISPLAY,"-------------- "); }
00280
00281 EnvPrintRouter(theEnv,WDISPLAY,"------- ------ ----- --------- ------\n");
00282 }
00283
00284 if (ProfileFunctionData(theEnv)->LastProfileInfo == USER_FUNCTIONS) OutputUserFunctionsInfo(theEnv);
00285 if (ProfileFunctionData(theEnv)->LastProfileInfo == CONSTRUCTS_CODE) OutputConstructsCodeInfo(theEnv);
00286 }
00287
00288
00289
00290
00291
00292 globle void StartProfile(
00293 void *theEnv,
00294 struct profileFrameInfo *theFrame,
00295 struct userData **theList,
00296 intBool checkFlag)
00297 {
00298 double startTime, addTime;
00299 struct constructProfileInfo *profileInfo;
00300
00301 if (! checkFlag)
00302 {
00303 theFrame->profileOnExit = FALSE;
00304 return;
00305 }
00306
00307 profileInfo = (struct constructProfileInfo *) FetchUserData(theEnv,ProfileFunctionData(theEnv)->ProfileDataID,theList);
00308
00309 theFrame->profileOnExit = TRUE;
00310 theFrame->parentCall = FALSE;
00311
00312 startTime = gentime();
00313 theFrame->oldProfileFrame = ProfileFunctionData(theEnv)->ActiveProfileFrame;
00314
00315 if (ProfileFunctionData(theEnv)->ActiveProfileFrame != NULL)
00316 {
00317 addTime = startTime - ProfileFunctionData(theEnv)->ActiveProfileFrame->startTime;
00318 ProfileFunctionData(theEnv)->ActiveProfileFrame->totalSelfTime += addTime;
00319 }
00320
00321 ProfileFunctionData(theEnv)->ActiveProfileFrame = profileInfo;
00322
00323 ProfileFunctionData(theEnv)->ActiveProfileFrame->numberOfEntries++;
00324 ProfileFunctionData(theEnv)->ActiveProfileFrame->startTime = startTime;
00325
00326 if (! ProfileFunctionData(theEnv)->ActiveProfileFrame->childCall)
00327 {
00328 theFrame->parentCall = TRUE;
00329 theFrame->parentStartTime = startTime;
00330 ProfileFunctionData(theEnv)->ActiveProfileFrame->childCall = TRUE;
00331 }
00332 }
00333
00334
00335
00336
00337
00338 globle void EndProfile(
00339 void *theEnv,
00340 struct profileFrameInfo *theFrame)
00341 {
00342 double endTime, addTime;
00343
00344 if (! theFrame->profileOnExit) return;
00345
00346 endTime = gentime();
00347
00348 if (theFrame->parentCall)
00349 {
00350 addTime = endTime - theFrame->parentStartTime;
00351 ProfileFunctionData(theEnv)->ActiveProfileFrame->totalWithChildrenTime += addTime;
00352 ProfileFunctionData(theEnv)->ActiveProfileFrame->childCall = FALSE;
00353 }
00354
00355 ProfileFunctionData(theEnv)->ActiveProfileFrame->totalSelfTime += (endTime - ProfileFunctionData(theEnv)->ActiveProfileFrame->startTime);
00356
00357 if (theFrame->oldProfileFrame != NULL)
00358 { theFrame->oldProfileFrame->startTime = endTime; }
00359
00360 ProfileFunctionData(theEnv)->ActiveProfileFrame = theFrame->oldProfileFrame;
00361 }
00362
00363
00364
00365
00366
00367 static intBool OutputProfileInfo(
00368 void *theEnv,
00369 char *itemName,
00370 struct constructProfileInfo *profileInfo,
00371 char *printPrefixBefore,
00372 char *printPrefix,
00373 char *printPrefixAfter,
00374 char **banner)
00375 {
00376 double percent = 0.0, percentWithKids = 0.0;
00377 char buffer[512];
00378
00379 if (profileInfo == NULL) return(FALSE);
00380
00381 if (profileInfo->numberOfEntries == 0) return(FALSE);
00382
00383 if (ProfileFunctionData(theEnv)->ProfileTotalTime != 0.0)
00384 {
00385 percent = (profileInfo->totalSelfTime * 100.0) / ProfileFunctionData(theEnv)->ProfileTotalTime;
00386 if (percent < 0.005) percent = 0.0;
00387 percentWithKids = (profileInfo->totalWithChildrenTime * 100.0) / ProfileFunctionData(theEnv)->ProfileTotalTime;
00388 if (percentWithKids < 0.005) percentWithKids = 0.0;
00389 }
00390
00391 if (percent < ProfileFunctionData(theEnv)->PercentThreshold) return(FALSE);
00392
00393 if ((banner != NULL) && (*banner != NULL))
00394 {
00395 EnvPrintRouter(theEnv,WDISPLAY,*banner);
00396 *banner = NULL;
00397 }
00398
00399 if (printPrefixBefore != NULL)
00400 { EnvPrintRouter(theEnv,WDISPLAY,printPrefixBefore); }
00401
00402 if (printPrefix != NULL)
00403 { EnvPrintRouter(theEnv,WDISPLAY,printPrefix); }
00404
00405 if (printPrefixAfter != NULL)
00406 { EnvPrintRouter(theEnv,WDISPLAY,printPrefixAfter); }
00407
00408 if (strlen(itemName) >= 40)
00409 {
00410 EnvPrintRouter(theEnv,WDISPLAY,itemName);
00411 EnvPrintRouter(theEnv,WDISPLAY,"\n");
00412 itemName = "";
00413 }
00414
00415 gensprintf(buffer,ProfileFunctionData(theEnv)->OutputString,
00416 itemName,
00417 (long) profileInfo->numberOfEntries,
00418
00419 (double) profileInfo->totalSelfTime,
00420 (double) percent,
00421
00422 (double) profileInfo->totalWithChildrenTime,
00423 (double) percentWithKids);
00424 EnvPrintRouter(theEnv,WDISPLAY,buffer);
00425
00426 return(TRUE);
00427 }
00428
00429
00430
00431
00432
00433 globle void ProfileResetCommand(
00434 void *theEnv)
00435 {
00436 struct FunctionDefinition *theFunction;
00437 int i;
00438 #if DEFFUNCTION_CONSTRUCT
00439 DEFFUNCTION *theDeffunction;
00440 #endif
00441 #if DEFRULE_CONSTRUCT
00442 struct defrule *theDefrule;
00443 #endif
00444 #if DEFGENERIC_CONSTRUCT
00445 DEFGENERIC *theDefgeneric;
00446 unsigned int methodIndex;
00447 DEFMETHOD *theMethod;
00448 #endif
00449 #if OBJECT_SYSTEM
00450 DEFCLASS *theDefclass;
00451 HANDLER *theHandler;
00452 unsigned handlerIndex;
00453 #endif
00454
00455 ProfileFunctionData(theEnv)->ProfileStartTime = 0.0;
00456 ProfileFunctionData(theEnv)->ProfileEndTime = 0.0;
00457 ProfileFunctionData(theEnv)->ProfileTotalTime = 0.0;
00458 ProfileFunctionData(theEnv)->LastProfileInfo = NO_PROFILE;
00459
00460 for (theFunction = GetFunctionList(theEnv);
00461 theFunction != NULL;
00462 theFunction = theFunction->next)
00463 {
00464 ResetProfileInfo((struct constructProfileInfo *)
00465 TestUserData(ProfileFunctionData(theEnv)->ProfileDataID,theFunction->usrData));
00466 }
00467
00468 for (i = 0; i < MAXIMUM_PRIMITIVES; i++)
00469 {
00470 if (EvaluationData(theEnv)->PrimitivesArray[i] != NULL)
00471 {
00472 ResetProfileInfo((struct constructProfileInfo *)
00473 TestUserData(ProfileFunctionData(theEnv)->ProfileDataID,EvaluationData(theEnv)->PrimitivesArray[i]->usrData));
00474 }
00475 }
00476
00477 #if DEFFUNCTION_CONSTRUCT
00478 for (theDeffunction = (DEFFUNCTION *) EnvGetNextDeffunction(theEnv,NULL);
00479 theDeffunction != NULL;
00480 theDeffunction = (DEFFUNCTION *) EnvGetNextDeffunction(theEnv,theDeffunction))
00481 {
00482 ResetProfileInfo((struct constructProfileInfo *)
00483 TestUserData(ProfileFunctionData(theEnv)->ProfileDataID,theDeffunction->header.usrData));
00484 }
00485 #endif
00486
00487 #if DEFRULE_CONSTRUCT
00488 for (theDefrule = (struct defrule *) EnvGetNextDefrule(theEnv,NULL);
00489 theDefrule != NULL;
00490 theDefrule = (struct defrule *) EnvGetNextDefrule(theEnv,theDefrule))
00491 {
00492 ResetProfileInfo((struct constructProfileInfo *)
00493 TestUserData(ProfileFunctionData(theEnv)->ProfileDataID,theDefrule->header.usrData));
00494 }
00495 #endif
00496
00497 #if DEFGENERIC_CONSTRUCT
00498 for (theDefgeneric = (DEFGENERIC *) EnvGetNextDefgeneric(theEnv,NULL);
00499 theDefgeneric != NULL;
00500 theDefgeneric = (DEFGENERIC *) EnvGetNextDefgeneric(theEnv,theDefgeneric))
00501 {
00502 ResetProfileInfo((struct constructProfileInfo *)
00503 TestUserData(ProfileFunctionData(theEnv)->ProfileDataID,theDefgeneric->header.usrData));
00504
00505 for (methodIndex = EnvGetNextDefmethod(theEnv,theDefgeneric,0);
00506 methodIndex != 0;
00507 methodIndex = EnvGetNextDefmethod(theEnv,theDefgeneric,methodIndex))
00508 {
00509 theMethod = GetDefmethodPointer(theDefgeneric,methodIndex);
00510 ResetProfileInfo((struct constructProfileInfo *)
00511 TestUserData(ProfileFunctionData(theEnv)->ProfileDataID,theMethod->usrData));
00512 }
00513 }
00514 #endif
00515
00516 #if OBJECT_SYSTEM
00517 for (theDefclass = (DEFCLASS *) EnvGetNextDefclass(theEnv,NULL);
00518 theDefclass != NULL;
00519 theDefclass = (DEFCLASS *) EnvGetNextDefclass(theEnv,theDefclass))
00520 {
00521 ResetProfileInfo((struct constructProfileInfo *)
00522 TestUserData(ProfileFunctionData(theEnv)->ProfileDataID,theDefclass->header.usrData));
00523 for (handlerIndex = EnvGetNextDefmessageHandler(theEnv,theDefclass,0);
00524 handlerIndex != 0;
00525 handlerIndex = EnvGetNextDefmessageHandler(theEnv,theDefclass,handlerIndex))
00526 {
00527 theHandler = GetDefmessageHandlerPointer(theDefclass,handlerIndex);
00528 ResetProfileInfo((struct constructProfileInfo *)
00529 TestUserData(ProfileFunctionData(theEnv)->ProfileDataID,theHandler->usrData));
00530 }
00531 }
00532 #endif
00533
00534 }
00535
00536
00537
00538
00539
00540 globle void ResetProfileInfo(
00541 struct constructProfileInfo *profileInfo)
00542 {
00543 if (profileInfo == NULL) return;
00544
00545 profileInfo->numberOfEntries = 0;
00546 profileInfo->childCall = FALSE;
00547 profileInfo->startTime = 0.0;
00548 profileInfo->totalSelfTime = 0.0;
00549 profileInfo->totalWithChildrenTime = 0.0;
00550 }
00551
00552
00553
00554
00555 static void OutputUserFunctionsInfo(
00556 void *theEnv)
00557 {
00558 struct FunctionDefinition *theFunction;
00559 int i;
00560
00561 for (theFunction = GetFunctionList(theEnv);
00562 theFunction != NULL;
00563 theFunction = theFunction->next)
00564 {
00565 OutputProfileInfo(theEnv,ValueToString(theFunction->callFunctionName),
00566 (struct constructProfileInfo *)
00567 TestUserData(ProfileFunctionData(theEnv)->ProfileDataID,
00568 theFunction->usrData),
00569 NULL,NULL,NULL,NULL);
00570 }
00571
00572 for (i = 0; i < MAXIMUM_PRIMITIVES; i++)
00573 {
00574 if (EvaluationData(theEnv)->PrimitivesArray[i] != NULL)
00575 {
00576 OutputProfileInfo(theEnv,EvaluationData(theEnv)->PrimitivesArray[i]->name,
00577 (struct constructProfileInfo *)
00578 TestUserData(ProfileFunctionData(theEnv)->ProfileDataID,
00579 EvaluationData(theEnv)->PrimitivesArray[i]->usrData),
00580 NULL,NULL,NULL,NULL);
00581 }
00582 }
00583 }
00584
00585
00586
00587
00588 #if WIN_BTC && (! DEFFUNCTION_CONSTRUCT) && (! DEFGENERIC_CONSTRUCT) && (! OBJECT_SYSTEM) && (! DEFRULE_CONSTRUCT)
00589 #pragma argsused
00590 #endif
00591 static void OutputConstructsCodeInfo(
00592 void *theEnv)
00593 {
00594 #if (! DEFFUNCTION_CONSTRUCT) && (! DEFGENERIC_CONSTRUCT) && (! OBJECT_SYSTEM) && (! DEFRULE_CONSTRUCT)
00595 #pragma unused(theEnv)
00596 #endif
00597 #if DEFFUNCTION_CONSTRUCT
00598 DEFFUNCTION *theDeffunction;
00599 #endif
00600 #if DEFRULE_CONSTRUCT
00601 struct defrule *theDefrule;
00602 #endif
00603 #if DEFGENERIC_CONSTRUCT
00604 DEFGENERIC *theDefgeneric;
00605 DEFMETHOD *theMethod;
00606 unsigned methodIndex;
00607 char methodBuffer[512];
00608 #endif
00609 #if OBJECT_SYSTEM
00610 DEFCLASS *theDefclass;
00611 HANDLER *theHandler;
00612 unsigned handlerIndex;
00613 #endif
00614 #if DEFGENERIC_CONSTRUCT || OBJECT_SYSTEM
00615 char *prefix, *prefixBefore, *prefixAfter;
00616 #endif
00617 char *banner;
00618
00619 banner = "\n*** Deffunctions ***\n\n";
00620
00621 #if DEFFUNCTION_CONSTRUCT
00622 for (theDeffunction = (DEFFUNCTION *) EnvGetNextDeffunction(theEnv,NULL);
00623 theDeffunction != NULL;
00624 theDeffunction = (DEFFUNCTION *) EnvGetNextDeffunction(theEnv,theDeffunction))
00625 {
00626 OutputProfileInfo(theEnv,EnvGetDeffunctionName(theEnv,theDeffunction),
00627 (struct constructProfileInfo *)
00628 TestUserData(ProfileFunctionData(theEnv)->ProfileDataID,theDeffunction->header.usrData),
00629 NULL,NULL,NULL,&banner);
00630 }
00631 #endif
00632
00633 banner = "\n*** Defgenerics ***\n";
00634 #if DEFGENERIC_CONSTRUCT
00635 for (theDefgeneric = (DEFGENERIC *) EnvGetNextDefgeneric(theEnv,NULL);
00636 theDefgeneric != NULL;
00637 theDefgeneric = (DEFGENERIC *) EnvGetNextDefgeneric(theEnv,theDefgeneric))
00638 {
00639 prefixBefore = "\n";
00640 prefix = EnvGetDefgenericName(theEnv,theDefgeneric);
00641 prefixAfter = "\n";
00642
00643 for (methodIndex = EnvGetNextDefmethod(theEnv,theDefgeneric,0);
00644 methodIndex != 0;
00645 methodIndex = EnvGetNextDefmethod(theEnv,theDefgeneric,methodIndex))
00646 {
00647 theMethod = GetDefmethodPointer(theDefgeneric,methodIndex);
00648
00649 EnvGetDefmethodDescription(theEnv,methodBuffer,510,theDefgeneric,methodIndex);
00650 if (OutputProfileInfo(theEnv,methodBuffer,
00651 (struct constructProfileInfo *)
00652 TestUserData(ProfileFunctionData(theEnv)->ProfileDataID,theMethod->usrData),
00653 prefixBefore,prefix,prefixAfter,&banner))
00654 {
00655 prefixBefore = NULL;
00656 prefix = NULL;
00657 prefixAfter = NULL;
00658 }
00659 }
00660 }
00661 #endif
00662
00663 banner = "\n*** Defclasses ***\n";
00664 #if OBJECT_SYSTEM
00665 for (theDefclass = (DEFCLASS *) EnvGetNextDefclass(theEnv,NULL);
00666 theDefclass != NULL;
00667 theDefclass = (DEFCLASS *) EnvGetNextDefclass(theEnv,theDefclass))
00668 {
00669 prefixAfter = "\n";
00670 prefix = EnvGetDefclassName(theEnv,theDefclass);
00671 prefixBefore = "\n";
00672
00673 for (handlerIndex = EnvGetNextDefmessageHandler(theEnv,theDefclass,0);
00674 handlerIndex != 0;
00675 handlerIndex = EnvGetNextDefmessageHandler(theEnv,theDefclass,handlerIndex))
00676 {
00677 theHandler = GetDefmessageHandlerPointer(theDefclass,handlerIndex);
00678 if (OutputProfileInfo(theEnv,EnvGetDefmessageHandlerName(theEnv,theDefclass,handlerIndex),
00679 (struct constructProfileInfo *)
00680 TestUserData(ProfileFunctionData(theEnv)->ProfileDataID,
00681 theHandler->usrData),
00682 prefixBefore,prefix,prefixAfter,&banner))
00683 {
00684 prefixBefore = NULL;
00685 prefix = NULL;
00686 prefixAfter = NULL;
00687 }
00688 }
00689
00690 }
00691 #endif
00692
00693 banner = "\n*** Defrules ***\n\n";
00694
00695 #if DEFRULE_CONSTRUCT
00696 for (theDefrule = (struct defrule *) EnvGetNextDefrule(theEnv,NULL);
00697 theDefrule != NULL;
00698 theDefrule = (struct defrule *) EnvGetNextDefrule(theEnv,theDefrule))
00699 {
00700 OutputProfileInfo(theEnv,EnvGetDefruleName(theEnv,theDefrule),
00701 (struct constructProfileInfo *)
00702 TestUserData(ProfileFunctionData(theEnv)->ProfileDataID,theDefrule->header.usrData),
00703 NULL,NULL,NULL,&banner);
00704 }
00705 #endif
00706
00707 }
00708
00709
00710
00711
00712
00713 globle double SetProfilePercentThresholdCommand(
00714 void *theEnv)
00715 {
00716 DATA_OBJECT theValue;
00717 double newThreshold;
00718
00719 if (EnvArgCountCheck(theEnv,"set-profile-percent-threshold",EXACTLY,1) == -1)
00720 { return(ProfileFunctionData(theEnv)->PercentThreshold); }
00721
00722 if (EnvArgTypeCheck(theEnv,"set-profile-percent-threshold",1,INTEGER_OR_FLOAT,&theValue) == FALSE)
00723 { return(ProfileFunctionData(theEnv)->PercentThreshold); }
00724
00725 if (GetType(theValue) == INTEGER)
00726 { newThreshold = (double) DOToLong(theValue); }
00727 else
00728 { newThreshold = (double) DOToDouble(theValue); }
00729
00730 if ((newThreshold < 0.0) || (newThreshold > 100.0))
00731 {
00732 ExpectedTypeError1(theEnv,"set-profile-percent-threshold",1,
00733 "number in the range 0 to 100");
00734 return(-1.0);
00735 }
00736
00737 return(SetProfilePercentThreshold(theEnv,newThreshold));
00738 }
00739
00740
00741
00742
00743
00744 globle double SetProfilePercentThreshold(
00745 void *theEnv,
00746 double value)
00747 {
00748 double oldPercentThreshhold;
00749
00750 if ((value < 0.0) || (value > 100.0))
00751 { return(-1.0); }
00752
00753 oldPercentThreshhold = ProfileFunctionData(theEnv)->PercentThreshold;
00754
00755 ProfileFunctionData(theEnv)->PercentThreshold = value;
00756
00757 return(oldPercentThreshhold);
00758 }
00759
00760
00761
00762
00763
00764 globle double GetProfilePercentThresholdCommand(
00765 void *theEnv)
00766 {
00767 EnvArgCountCheck(theEnv,"get-profile-percent-threshold",EXACTLY,0);
00768
00769 return(ProfileFunctionData(theEnv)->PercentThreshold);
00770 }
00771
00772
00773
00774
00775
00776 globle double GetProfilePercentThreshold(
00777 void *theEnv)
00778 {
00779 return(ProfileFunctionData(theEnv)->PercentThreshold);
00780 }
00781
00782
00783
00784
00785 globle char *SetProfileOutputString(
00786 void *theEnv,
00787 char *value)
00788 {
00789 char *oldOutputString;
00790
00791 if (value == NULL)
00792 { return(ProfileFunctionData(theEnv)->OutputString); }
00793
00794 oldOutputString = ProfileFunctionData(theEnv)->OutputString;
00795
00796 ProfileFunctionData(theEnv)->OutputString = value;
00797
00798 return(oldOutputString);
00799 }
00800
00801 #if (! RUN_TIME)
00802
00803
00804
00805
00806 static void ProfileClearFunction(
00807 void *theEnv)
00808 {
00809 struct FunctionDefinition *theFunction;
00810 int i;
00811
00812 for (theFunction = GetFunctionList(theEnv);
00813 theFunction != NULL;
00814 theFunction = theFunction->next)
00815 {
00816 theFunction->usrData =
00817 DeleteUserData(theEnv,ProfileFunctionData(theEnv)->ProfileDataID,theFunction->usrData);
00818 }
00819
00820 for (i = 0; i < MAXIMUM_PRIMITIVES; i++)
00821 {
00822 if (EvaluationData(theEnv)->PrimitivesArray[i] != NULL)
00823 {
00824 EvaluationData(theEnv)->PrimitivesArray[i]->usrData =
00825 DeleteUserData(theEnv,ProfileFunctionData(theEnv)->ProfileDataID,EvaluationData(theEnv)->PrimitivesArray[i]->usrData);
00826 }
00827 }
00828 }
00829 #endif
00830
00831 #endif
00832