clipsruby 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/ext/clipsruby/agenda.c +1373 -0
- data/ext/clipsruby/agenda.h +169 -0
- data/ext/clipsruby/analysis.c +1142 -0
- data/ext/clipsruby/analysis.h +61 -0
- data/ext/clipsruby/argacces.c +526 -0
- data/ext/clipsruby/argacces.h +77 -0
- data/ext/clipsruby/bload.c +884 -0
- data/ext/clipsruby/bload.h +94 -0
- data/ext/clipsruby/bmathfun.c +557 -0
- data/ext/clipsruby/bmathfun.h +66 -0
- data/ext/clipsruby/bsave.c +634 -0
- data/ext/clipsruby/bsave.h +130 -0
- data/ext/clipsruby/classcom.c +976 -0
- data/ext/clipsruby/classcom.h +115 -0
- data/ext/clipsruby/classexm.c +1376 -0
- data/ext/clipsruby/classexm.h +97 -0
- data/ext/clipsruby/classfun.c +1392 -0
- data/ext/clipsruby/classfun.h +164 -0
- data/ext/clipsruby/classinf.c +1245 -0
- data/ext/clipsruby/classinf.h +94 -0
- data/ext/clipsruby/classini.c +843 -0
- data/ext/clipsruby/classini.h +75 -0
- data/ext/clipsruby/classpsr.c +957 -0
- data/ext/clipsruby/classpsr.h +73 -0
- data/ext/clipsruby/clips.h +133 -0
- data/ext/clipsruby/clipsruby.c +619 -0
- data/ext/clipsruby/clsltpsr.c +931 -0
- data/ext/clipsruby/clsltpsr.h +72 -0
- data/ext/clipsruby/commline.c +1217 -0
- data/ext/clipsruby/commline.h +131 -0
- data/ext/clipsruby/conscomp.c +1593 -0
- data/ext/clipsruby/conscomp.h +150 -0
- data/ext/clipsruby/constant.h +264 -0
- data/ext/clipsruby/constrct.c +1090 -0
- data/ext/clipsruby/constrct.h +216 -0
- data/ext/clipsruby/constrnt.c +554 -0
- data/ext/clipsruby/constrnt.h +132 -0
- data/ext/clipsruby/crstrtgy.c +1088 -0
- data/ext/clipsruby/crstrtgy.h +85 -0
- data/ext/clipsruby/cstrcbin.c +185 -0
- data/ext/clipsruby/cstrcbin.h +61 -0
- data/ext/clipsruby/cstrccmp.h +43 -0
- data/ext/clipsruby/cstrccom.c +1791 -0
- data/ext/clipsruby/cstrccom.h +115 -0
- data/ext/clipsruby/cstrcpsr.c +835 -0
- data/ext/clipsruby/cstrcpsr.h +97 -0
- data/ext/clipsruby/cstrnbin.c +282 -0
- data/ext/clipsruby/cstrnbin.h +55 -0
- data/ext/clipsruby/cstrnchk.c +826 -0
- data/ext/clipsruby/cstrnchk.h +91 -0
- data/ext/clipsruby/cstrncmp.c +238 -0
- data/ext/clipsruby/cstrncmp.h +57 -0
- data/ext/clipsruby/cstrnops.c +1176 -0
- data/ext/clipsruby/cstrnops.h +47 -0
- data/ext/clipsruby/cstrnpsr.c +1394 -0
- data/ext/clipsruby/cstrnpsr.h +88 -0
- data/ext/clipsruby/cstrnutl.c +564 -0
- data/ext/clipsruby/cstrnutl.h +54 -0
- data/ext/clipsruby/default.c +454 -0
- data/ext/clipsruby/default.h +57 -0
- data/ext/clipsruby/defins.c +971 -0
- data/ext/clipsruby/defins.h +127 -0
- data/ext/clipsruby/developr.c +677 -0
- data/ext/clipsruby/developr.h +69 -0
- data/ext/clipsruby/dffctbin.c +477 -0
- data/ext/clipsruby/dffctbin.h +76 -0
- data/ext/clipsruby/dffctbsc.c +308 -0
- data/ext/clipsruby/dffctbsc.h +72 -0
- data/ext/clipsruby/dffctcmp.c +297 -0
- data/ext/clipsruby/dffctcmp.h +44 -0
- data/ext/clipsruby/dffctdef.c +364 -0
- data/ext/clipsruby/dffctdef.h +104 -0
- data/ext/clipsruby/dffctpsr.c +179 -0
- data/ext/clipsruby/dffctpsr.h +49 -0
- data/ext/clipsruby/dffnxbin.c +520 -0
- data/ext/clipsruby/dffnxbin.h +67 -0
- data/ext/clipsruby/dffnxcmp.c +378 -0
- data/ext/clipsruby/dffnxcmp.h +54 -0
- data/ext/clipsruby/dffnxexe.c +241 -0
- data/ext/clipsruby/dffnxexe.h +58 -0
- data/ext/clipsruby/dffnxfun.c +1192 -0
- data/ext/clipsruby/dffnxfun.h +155 -0
- data/ext/clipsruby/dffnxpsr.c +514 -0
- data/ext/clipsruby/dffnxpsr.h +57 -0
- data/ext/clipsruby/dfinsbin.c +509 -0
- data/ext/clipsruby/dfinsbin.h +66 -0
- data/ext/clipsruby/dfinscmp.c +345 -0
- data/ext/clipsruby/dfinscmp.h +48 -0
- data/ext/clipsruby/drive.c +1191 -0
- data/ext/clipsruby/drive.h +65 -0
- data/ext/clipsruby/emathfun.c +1213 -0
- data/ext/clipsruby/emathfun.h +99 -0
- data/ext/clipsruby/engine.c +1568 -0
- data/ext/clipsruby/engine.h +203 -0
- data/ext/clipsruby/entities.h +276 -0
- data/ext/clipsruby/envrnbld.c +514 -0
- data/ext/clipsruby/envrnbld.h +40 -0
- data/ext/clipsruby/envrnmnt.c +257 -0
- data/ext/clipsruby/envrnmnt.h +112 -0
- data/ext/clipsruby/evaluatn.c +1736 -0
- data/ext/clipsruby/evaluatn.h +211 -0
- data/ext/clipsruby/expressn.c +494 -0
- data/ext/clipsruby/expressn.h +154 -0
- data/ext/clipsruby/exprnbin.c +538 -0
- data/ext/clipsruby/exprnbin.h +60 -0
- data/ext/clipsruby/exprnops.c +564 -0
- data/ext/clipsruby/exprnops.h +67 -0
- data/ext/clipsruby/exprnpsr.c +1112 -0
- data/ext/clipsruby/exprnpsr.h +98 -0
- data/ext/clipsruby/extconf.rb +2 -0
- data/ext/clipsruby/extnfunc.c +1015 -0
- data/ext/clipsruby/extnfunc.h +157 -0
- data/ext/clipsruby/factbin.c +447 -0
- data/ext/clipsruby/factbin.h +56 -0
- data/ext/clipsruby/factbld.c +1035 -0
- data/ext/clipsruby/factbld.h +63 -0
- data/ext/clipsruby/factcmp.c +386 -0
- data/ext/clipsruby/factcmp.h +46 -0
- data/ext/clipsruby/factcom.c +759 -0
- data/ext/clipsruby/factcom.h +80 -0
- data/ext/clipsruby/factfile.c +1761 -0
- data/ext/clipsruby/factfile.h +54 -0
- data/ext/clipsruby/factfun.c +682 -0
- data/ext/clipsruby/factfun.h +77 -0
- data/ext/clipsruby/factgen.c +1305 -0
- data/ext/clipsruby/factgen.h +229 -0
- data/ext/clipsruby/facthsh.c +438 -0
- data/ext/clipsruby/facthsh.h +81 -0
- data/ext/clipsruby/factlhs.c +250 -0
- data/ext/clipsruby/factlhs.h +54 -0
- data/ext/clipsruby/factmch.c +905 -0
- data/ext/clipsruby/factmch.h +68 -0
- data/ext/clipsruby/factmngr.c +3373 -0
- data/ext/clipsruby/factmngr.h +325 -0
- data/ext/clipsruby/factprt.c +498 -0
- data/ext/clipsruby/factprt.h +60 -0
- data/ext/clipsruby/factqpsr.c +796 -0
- data/ext/clipsruby/factqpsr.h +61 -0
- data/ext/clipsruby/factqury.c +1267 -0
- data/ext/clipsruby/factqury.h +112 -0
- data/ext/clipsruby/factrete.c +978 -0
- data/ext/clipsruby/factrete.h +70 -0
- data/ext/clipsruby/factrhs.c +667 -0
- data/ext/clipsruby/factrhs.h +55 -0
- data/ext/clipsruby/filecom.c +353 -0
- data/ext/clipsruby/filecom.h +137 -0
- data/ext/clipsruby/filertr.c +481 -0
- data/ext/clipsruby/filertr.h +94 -0
- data/ext/clipsruby/fileutil.c +1020 -0
- data/ext/clipsruby/fileutil.h +50 -0
- data/ext/clipsruby/generate.c +1079 -0
- data/ext/clipsruby/generate.h +57 -0
- data/ext/clipsruby/genrcbin.c +902 -0
- data/ext/clipsruby/genrcbin.h +69 -0
- data/ext/clipsruby/genrccmp.c +640 -0
- data/ext/clipsruby/genrccmp.h +59 -0
- data/ext/clipsruby/genrccom.c +2017 -0
- data/ext/clipsruby/genrccom.h +119 -0
- data/ext/clipsruby/genrcexe.c +737 -0
- data/ext/clipsruby/genrcexe.h +73 -0
- data/ext/clipsruby/genrcfun.c +890 -0
- data/ext/clipsruby/genrcfun.h +185 -0
- data/ext/clipsruby/genrcpsr.c +1618 -0
- data/ext/clipsruby/genrcpsr.h +80 -0
- data/ext/clipsruby/globlbin.c +458 -0
- data/ext/clipsruby/globlbin.h +71 -0
- data/ext/clipsruby/globlbsc.c +361 -0
- data/ext/clipsruby/globlbsc.h +83 -0
- data/ext/clipsruby/globlcmp.c +330 -0
- data/ext/clipsruby/globlcmp.h +52 -0
- data/ext/clipsruby/globlcom.c +289 -0
- data/ext/clipsruby/globlcom.h +63 -0
- data/ext/clipsruby/globldef.c +1087 -0
- data/ext/clipsruby/globldef.h +151 -0
- data/ext/clipsruby/globlpsr.c +530 -0
- data/ext/clipsruby/globlpsr.h +59 -0
- data/ext/clipsruby/immthpsr.c +431 -0
- data/ext/clipsruby/immthpsr.h +55 -0
- data/ext/clipsruby/incrrset.c +530 -0
- data/ext/clipsruby/incrrset.h +73 -0
- data/ext/clipsruby/inherpsr.c +850 -0
- data/ext/clipsruby/inherpsr.h +52 -0
- data/ext/clipsruby/inscom.c +2076 -0
- data/ext/clipsruby/inscom.h +182 -0
- data/ext/clipsruby/insfile.c +1764 -0
- data/ext/clipsruby/insfile.h +96 -0
- data/ext/clipsruby/insfun.c +1451 -0
- data/ext/clipsruby/insfun.h +134 -0
- data/ext/clipsruby/insmngr.c +2550 -0
- data/ext/clipsruby/insmngr.h +125 -0
- data/ext/clipsruby/insmoddp.c +1041 -0
- data/ext/clipsruby/insmoddp.h +91 -0
- data/ext/clipsruby/insmult.c +804 -0
- data/ext/clipsruby/insmult.h +62 -0
- data/ext/clipsruby/inspsr.c +602 -0
- data/ext/clipsruby/inspsr.h +60 -0
- data/ext/clipsruby/insquery.c +1278 -0
- data/ext/clipsruby/insquery.h +115 -0
- data/ext/clipsruby/insqypsr.c +729 -0
- data/ext/clipsruby/insqypsr.h +63 -0
- data/ext/clipsruby/iofun.c +2045 -0
- data/ext/clipsruby/iofun.h +116 -0
- data/ext/clipsruby/lgcldpnd.c +644 -0
- data/ext/clipsruby/lgcldpnd.h +75 -0
- data/ext/clipsruby/main.c +112 -0
- data/ext/clipsruby/match.h +142 -0
- data/ext/clipsruby/memalloc.c +481 -0
- data/ext/clipsruby/memalloc.h +197 -0
- data/ext/clipsruby/miscfun.c +1801 -0
- data/ext/clipsruby/miscfun.h +132 -0
- data/ext/clipsruby/modulbin.c +607 -0
- data/ext/clipsruby/modulbin.h +84 -0
- data/ext/clipsruby/modulbsc.c +347 -0
- data/ext/clipsruby/modulbsc.h +67 -0
- data/ext/clipsruby/modulcmp.c +499 -0
- data/ext/clipsruby/modulcmp.h +54 -0
- data/ext/clipsruby/moduldef.c +817 -0
- data/ext/clipsruby/moduldef.h +271 -0
- data/ext/clipsruby/modulpsr.c +1150 -0
- data/ext/clipsruby/modulpsr.h +69 -0
- data/ext/clipsruby/modulutl.c +1036 -0
- data/ext/clipsruby/modulutl.h +84 -0
- data/ext/clipsruby/msgcom.c +1221 -0
- data/ext/clipsruby/msgcom.h +125 -0
- data/ext/clipsruby/msgfun.c +1076 -0
- data/ext/clipsruby/msgfun.h +118 -0
- data/ext/clipsruby/msgpass.c +1441 -0
- data/ext/clipsruby/msgpass.h +103 -0
- data/ext/clipsruby/msgpsr.c +698 -0
- data/ext/clipsruby/msgpsr.h +73 -0
- data/ext/clipsruby/multifld.c +1404 -0
- data/ext/clipsruby/multifld.h +130 -0
- data/ext/clipsruby/multifun.c +2182 -0
- data/ext/clipsruby/multifun.h +102 -0
- data/ext/clipsruby/network.h +142 -0
- data/ext/clipsruby/objbin.c +1522 -0
- data/ext/clipsruby/objbin.h +79 -0
- data/ext/clipsruby/objcmp.c +1507 -0
- data/ext/clipsruby/objcmp.h +71 -0
- data/ext/clipsruby/object.h +260 -0
- data/ext/clipsruby/objrtbin.c +701 -0
- data/ext/clipsruby/objrtbin.h +79 -0
- data/ext/clipsruby/objrtbld.c +2393 -0
- data/ext/clipsruby/objrtbld.h +66 -0
- data/ext/clipsruby/objrtcmp.c +734 -0
- data/ext/clipsruby/objrtcmp.h +66 -0
- data/ext/clipsruby/objrtfnx.c +1330 -0
- data/ext/clipsruby/objrtfnx.h +222 -0
- data/ext/clipsruby/objrtgen.c +736 -0
- data/ext/clipsruby/objrtgen.h +63 -0
- data/ext/clipsruby/objrtmch.c +1524 -0
- data/ext/clipsruby/objrtmch.h +160 -0
- data/ext/clipsruby/parsefun.c +415 -0
- data/ext/clipsruby/parsefun.h +67 -0
- data/ext/clipsruby/pattern.c +1265 -0
- data/ext/clipsruby/pattern.h +163 -0
- data/ext/clipsruby/pprint.c +328 -0
- data/ext/clipsruby/pprint.h +79 -0
- data/ext/clipsruby/prccode.c +1478 -0
- data/ext/clipsruby/prccode.h +145 -0
- data/ext/clipsruby/prcdrfun.c +640 -0
- data/ext/clipsruby/prcdrfun.h +95 -0
- data/ext/clipsruby/prcdrpsr.c +1068 -0
- data/ext/clipsruby/prcdrpsr.h +79 -0
- data/ext/clipsruby/prdctfun.c +869 -0
- data/ext/clipsruby/prdctfun.h +77 -0
- data/ext/clipsruby/prntutil.c +878 -0
- data/ext/clipsruby/prntutil.h +125 -0
- data/ext/clipsruby/proflfun.c +827 -0
- data/ext/clipsruby/proflfun.h +118 -0
- data/ext/clipsruby/reorder.c +2082 -0
- data/ext/clipsruby/reorder.h +172 -0
- data/ext/clipsruby/reteutil.c +1732 -0
- data/ext/clipsruby/reteutil.h +111 -0
- data/ext/clipsruby/retract.c +710 -0
- data/ext/clipsruby/retract.h +74 -0
- data/ext/clipsruby/router.c +737 -0
- data/ext/clipsruby/router.h +147 -0
- data/ext/clipsruby/rulebin.c +1136 -0
- data/ext/clipsruby/rulebin.h +153 -0
- data/ext/clipsruby/rulebld.c +1328 -0
- data/ext/clipsruby/rulebld.h +62 -0
- data/ext/clipsruby/rulebsc.c +517 -0
- data/ext/clipsruby/rulebsc.h +91 -0
- data/ext/clipsruby/rulecmp.c +733 -0
- data/ext/clipsruby/rulecmp.h +63 -0
- data/ext/clipsruby/rulecom.c +1583 -0
- data/ext/clipsruby/rulecom.h +116 -0
- data/ext/clipsruby/rulecstr.c +892 -0
- data/ext/clipsruby/rulecstr.h +53 -0
- data/ext/clipsruby/ruledef.c +559 -0
- data/ext/clipsruby/ruledef.h +179 -0
- data/ext/clipsruby/ruledlt.c +599 -0
- data/ext/clipsruby/ruledlt.h +58 -0
- data/ext/clipsruby/rulelhs.c +1216 -0
- data/ext/clipsruby/rulelhs.h +52 -0
- data/ext/clipsruby/rulepsr.c +1073 -0
- data/ext/clipsruby/rulepsr.h +61 -0
- data/ext/clipsruby/scanner.c +856 -0
- data/ext/clipsruby/scanner.h +112 -0
- data/ext/clipsruby/setup.h +488 -0
- data/ext/clipsruby/sortfun.c +433 -0
- data/ext/clipsruby/sortfun.h +55 -0
- data/ext/clipsruby/strngfun.c +1173 -0
- data/ext/clipsruby/strngfun.h +96 -0
- data/ext/clipsruby/strngrtr.c +523 -0
- data/ext/clipsruby/strngrtr.h +97 -0
- data/ext/clipsruby/symblbin.c +648 -0
- data/ext/clipsruby/symblbin.h +64 -0
- data/ext/clipsruby/symblcmp.c +893 -0
- data/ext/clipsruby/symblcmp.h +61 -0
- data/ext/clipsruby/symbol.c +1961 -0
- data/ext/clipsruby/symbol.h +243 -0
- data/ext/clipsruby/sysdep.c +894 -0
- data/ext/clipsruby/sysdep.h +164 -0
- data/ext/clipsruby/textpro.c +1388 -0
- data/ext/clipsruby/textpro.h +77 -0
- data/ext/clipsruby/tmpltbin.c +609 -0
- data/ext/clipsruby/tmpltbin.h +108 -0
- data/ext/clipsruby/tmpltbsc.c +327 -0
- data/ext/clipsruby/tmpltbsc.h +87 -0
- data/ext/clipsruby/tmpltcmp.c +450 -0
- data/ext/clipsruby/tmpltcmp.h +57 -0
- data/ext/clipsruby/tmpltdef.c +584 -0
- data/ext/clipsruby/tmpltdef.h +155 -0
- data/ext/clipsruby/tmpltfun.c +2477 -0
- data/ext/clipsruby/tmpltfun.h +122 -0
- data/ext/clipsruby/tmpltlhs.c +379 -0
- data/ext/clipsruby/tmpltlhs.h +50 -0
- data/ext/clipsruby/tmpltpsr.c +819 -0
- data/ext/clipsruby/tmpltpsr.h +59 -0
- data/ext/clipsruby/tmpltrhs.c +595 -0
- data/ext/clipsruby/tmpltrhs.h +55 -0
- data/ext/clipsruby/tmpltutl.c +637 -0
- data/ext/clipsruby/tmpltutl.h +82 -0
- data/ext/clipsruby/userdata.c +156 -0
- data/ext/clipsruby/userdata.h +72 -0
- data/ext/clipsruby/userfunctions.c +70 -0
- data/ext/clipsruby/usrsetup.h +7 -0
- data/ext/clipsruby/utility.c +1594 -0
- data/ext/clipsruby/utility.h +250 -0
- data/ext/clipsruby/watch.c +865 -0
- data/ext/clipsruby/watch.h +124 -0
- data/lib/clipsruby.rb +1 -0
- metadata +388 -0
@@ -0,0 +1,827 @@
|
|
1
|
+
/*******************************************************/
|
2
|
+
/* "C" Language Integrated Production System */
|
3
|
+
/* */
|
4
|
+
/* CLIPS Version 6.41 12/04/22 */
|
5
|
+
/* */
|
6
|
+
/* CONSTRUCT PROFILING FUNCTIONS MODULE */
|
7
|
+
/*******************************************************/
|
8
|
+
|
9
|
+
/*************************************************************/
|
10
|
+
/* Purpose: Contains the code for profiling the amount of */
|
11
|
+
/* time spent in constructs and user defined functions. */
|
12
|
+
/* */
|
13
|
+
/* Principal Programmer(s): */
|
14
|
+
/* Gary D. Riley */
|
15
|
+
/* */
|
16
|
+
/* Contributing Programmer(s): */
|
17
|
+
/* */
|
18
|
+
/* Revision History: */
|
19
|
+
/* */
|
20
|
+
/* 6.23: Modified OutputProfileInfo to allow a before */
|
21
|
+
/* and after prefix so that a string buffer does */
|
22
|
+
/* not need to be created to contain the entire */
|
23
|
+
/* prefix. This allows a buffer overflow problem */
|
24
|
+
/* to be corrected. DR0857. */
|
25
|
+
/* */
|
26
|
+
/* 6.24: Renamed BOOLEAN macro type to intBool. */
|
27
|
+
/* */
|
28
|
+
/* Added pragmas to remove compilation warnings. */
|
29
|
+
/* */
|
30
|
+
/* Corrected code to remove run-time program */
|
31
|
+
/* compiler warnings. */
|
32
|
+
/* */
|
33
|
+
/* 6.30: Used gensprintf instead of sprintf. */
|
34
|
+
/* */
|
35
|
+
/* Removed conditional code for unsupported */
|
36
|
+
/* compilers/operating systems (IBM_TBC). */
|
37
|
+
/* */
|
38
|
+
/* Added const qualifiers to remove C++ */
|
39
|
+
/* deprecation warnings. */
|
40
|
+
/* */
|
41
|
+
/* 6.40: Pragma once and other inclusion changes. */
|
42
|
+
/* */
|
43
|
+
/* Added support for booleans with <stdbool.h>. */
|
44
|
+
/* */
|
45
|
+
/* Removed use of void pointers for specific */
|
46
|
+
/* data structures. */
|
47
|
+
/* */
|
48
|
+
/* UDF redesign. */
|
49
|
+
/* */
|
50
|
+
/* 6.41: Used gensnprintf in place of gensprintf and. */
|
51
|
+
/* sprintf. */
|
52
|
+
/* */
|
53
|
+
/*************************************************************/
|
54
|
+
|
55
|
+
#include "setup.h"
|
56
|
+
|
57
|
+
#if PROFILING_FUNCTIONS
|
58
|
+
|
59
|
+
#include "argacces.h"
|
60
|
+
#include "classcom.h"
|
61
|
+
#include "dffnxfun.h"
|
62
|
+
#include "envrnmnt.h"
|
63
|
+
#include "extnfunc.h"
|
64
|
+
#include "genrccom.h"
|
65
|
+
#include "genrcfun.h"
|
66
|
+
#include "memalloc.h"
|
67
|
+
#include "msgcom.h"
|
68
|
+
#include "router.h"
|
69
|
+
#include "sysdep.h"
|
70
|
+
|
71
|
+
#include "proflfun.h"
|
72
|
+
|
73
|
+
#include <string.h>
|
74
|
+
|
75
|
+
#define NO_PROFILE 0
|
76
|
+
#define USER_FUNCTIONS 1
|
77
|
+
#define CONSTRUCTS_CODE 2
|
78
|
+
|
79
|
+
#define OUTPUT_STRING "%-40s %7ld %15.6f %8.2f%% %15.6f %8.2f%%\n"
|
80
|
+
|
81
|
+
/***************************************/
|
82
|
+
/* LOCAL INTERNAL FUNCTION DEFINITIONS */
|
83
|
+
/***************************************/
|
84
|
+
|
85
|
+
static bool OutputProfileInfo(Environment *,const char *,struct constructProfileInfo *,
|
86
|
+
const char *,const char *,const char *,const char **);
|
87
|
+
static void OutputUserFunctionsInfo(Environment *);
|
88
|
+
static void OutputConstructsCodeInfo(Environment *);
|
89
|
+
#if (! RUN_TIME)
|
90
|
+
static void ProfileClearFunction(Environment *,void *);
|
91
|
+
#endif
|
92
|
+
|
93
|
+
/******************************************************/
|
94
|
+
/* ConstructProfilingFunctionDefinitions: Initializes */
|
95
|
+
/* the construct profiling functions. */
|
96
|
+
/******************************************************/
|
97
|
+
void ConstructProfilingFunctionDefinitions(
|
98
|
+
Environment *theEnv)
|
99
|
+
{
|
100
|
+
struct userDataRecord profileDataInfo = { 0, CreateProfileData, DeleteProfileData };
|
101
|
+
|
102
|
+
AllocateEnvironmentData(theEnv,PROFLFUN_DATA,sizeof(struct profileFunctionData),NULL);
|
103
|
+
|
104
|
+
memcpy(&ProfileFunctionData(theEnv)->ProfileDataInfo,&profileDataInfo,sizeof(struct userDataRecord));
|
105
|
+
|
106
|
+
ProfileFunctionData(theEnv)->LastProfileInfo = NO_PROFILE;
|
107
|
+
ProfileFunctionData(theEnv)->PercentThreshold = 0.0;
|
108
|
+
ProfileFunctionData(theEnv)->OutputString = OUTPUT_STRING;
|
109
|
+
|
110
|
+
#if ! RUN_TIME
|
111
|
+
AddUDF(theEnv,"profile","v",1,1,"y",ProfileCommand,"ProfileCommand",NULL);
|
112
|
+
AddUDF(theEnv,"profile-info","v",0,0,NULL, ProfileInfoCommand,"ProfileInfoCommand",NULL);
|
113
|
+
AddUDF(theEnv,"profile-reset","v",0,0,NULL,ProfileResetCommand,"ProfileResetCommand",NULL);
|
114
|
+
|
115
|
+
AddUDF(theEnv,"set-profile-percent-threshold","d",1,1,"ld",SetProfilePercentThresholdCommand,"SetProfilePercentThresholdCommand",NULL);
|
116
|
+
AddUDF(theEnv,"get-profile-percent-threshold","d",0,0,NULL,GetProfilePercentThresholdCommand,"GetProfilePercentThresholdCommand",NULL);
|
117
|
+
|
118
|
+
ProfileFunctionData(theEnv)->ProfileDataID = InstallUserDataRecord(theEnv,&ProfileFunctionData(theEnv)->ProfileDataInfo);
|
119
|
+
|
120
|
+
AddClearFunction(theEnv,"profile",ProfileClearFunction,0,NULL);
|
121
|
+
#endif
|
122
|
+
}
|
123
|
+
|
124
|
+
/**********************************/
|
125
|
+
/* CreateProfileData: Allocates a */
|
126
|
+
/* profile user data structure. */
|
127
|
+
/**********************************/
|
128
|
+
void *CreateProfileData(
|
129
|
+
Environment *theEnv)
|
130
|
+
{
|
131
|
+
struct constructProfileInfo *theInfo;
|
132
|
+
|
133
|
+
theInfo = (struct constructProfileInfo *)
|
134
|
+
genalloc(theEnv,sizeof(struct constructProfileInfo));
|
135
|
+
|
136
|
+
theInfo->numberOfEntries = 0;
|
137
|
+
theInfo->childCall = false;
|
138
|
+
theInfo->startTime = 0.0;
|
139
|
+
theInfo->totalSelfTime = 0.0;
|
140
|
+
theInfo->totalWithChildrenTime = 0.0;
|
141
|
+
|
142
|
+
return(theInfo);
|
143
|
+
}
|
144
|
+
|
145
|
+
/**************************************/
|
146
|
+
/* DeleteProfileData: */
|
147
|
+
/**************************************/
|
148
|
+
void DeleteProfileData(
|
149
|
+
Environment *theEnv,
|
150
|
+
void *theData)
|
151
|
+
{
|
152
|
+
genfree(theEnv,theData,sizeof(struct constructProfileInfo));
|
153
|
+
}
|
154
|
+
|
155
|
+
/**************************************/
|
156
|
+
/* ProfileCommand: H/L access routine */
|
157
|
+
/* for the profile command. */
|
158
|
+
/**************************************/
|
159
|
+
void ProfileCommand(
|
160
|
+
Environment *theEnv,
|
161
|
+
UDFContext *context,
|
162
|
+
UDFValue *returnValue)
|
163
|
+
{
|
164
|
+
const char *argument;
|
165
|
+
UDFValue theValue;
|
166
|
+
|
167
|
+
if (! UDFFirstArgument(context,SYMBOL_BIT,&theValue)) return;
|
168
|
+
argument = theValue.lexemeValue->contents;
|
169
|
+
|
170
|
+
if (! Profile(theEnv,argument))
|
171
|
+
{
|
172
|
+
UDFInvalidArgumentMessage(context,"symbol with value constructs, user-functions, or off");
|
173
|
+
return;
|
174
|
+
}
|
175
|
+
|
176
|
+
return;
|
177
|
+
}
|
178
|
+
|
179
|
+
/******************************/
|
180
|
+
/* Profile: C access routine */
|
181
|
+
/* for the profile command. */
|
182
|
+
/******************************/
|
183
|
+
bool Profile(
|
184
|
+
Environment *theEnv,
|
185
|
+
const char *argument)
|
186
|
+
{
|
187
|
+
/*======================================================*/
|
188
|
+
/* If the argument is the symbol "user-functions", then */
|
189
|
+
/* user-defined functions should be profiled. If the */
|
190
|
+
/* argument is the symbol "constructs", then */
|
191
|
+
/* deffunctions, generic functions, message-handlers, */
|
192
|
+
/* and rule RHS actions are profiled. */
|
193
|
+
/*======================================================*/
|
194
|
+
|
195
|
+
if (strcmp(argument,"user-functions") == 0)
|
196
|
+
{
|
197
|
+
ProfileFunctionData(theEnv)->ProfileStartTime = gentime();
|
198
|
+
ProfileFunctionData(theEnv)->ProfileUserFunctions = true;
|
199
|
+
ProfileFunctionData(theEnv)->ProfileConstructs = false;
|
200
|
+
ProfileFunctionData(theEnv)->LastProfileInfo = USER_FUNCTIONS;
|
201
|
+
}
|
202
|
+
|
203
|
+
else if (strcmp(argument,"constructs") == 0)
|
204
|
+
{
|
205
|
+
ProfileFunctionData(theEnv)->ProfileStartTime = gentime();
|
206
|
+
ProfileFunctionData(theEnv)->ProfileUserFunctions = false;
|
207
|
+
ProfileFunctionData(theEnv)->ProfileConstructs = true;
|
208
|
+
ProfileFunctionData(theEnv)->LastProfileInfo = CONSTRUCTS_CODE;
|
209
|
+
}
|
210
|
+
|
211
|
+
/*======================================================*/
|
212
|
+
/* Otherwise, if the argument is the symbol "off", then */
|
213
|
+
/* don't profile constructs and user-defined functions. */
|
214
|
+
/*======================================================*/
|
215
|
+
|
216
|
+
else if (strcmp(argument,"off") == 0)
|
217
|
+
{
|
218
|
+
ProfileFunctionData(theEnv)->ProfileEndTime = gentime();
|
219
|
+
ProfileFunctionData(theEnv)->ProfileTotalTime += (ProfileFunctionData(theEnv)->ProfileEndTime - ProfileFunctionData(theEnv)->ProfileStartTime);
|
220
|
+
ProfileFunctionData(theEnv)->ProfileUserFunctions = false;
|
221
|
+
ProfileFunctionData(theEnv)->ProfileConstructs = false;
|
222
|
+
}
|
223
|
+
|
224
|
+
/*=====================================================*/
|
225
|
+
/* Otherwise, generate an error since the only allowed */
|
226
|
+
/* arguments are "on" or "off." */
|
227
|
+
/*=====================================================*/
|
228
|
+
|
229
|
+
else
|
230
|
+
{ return false; }
|
231
|
+
|
232
|
+
return true;
|
233
|
+
}
|
234
|
+
|
235
|
+
/******************************************/
|
236
|
+
/* ProfileInfoCommand: H/L access routine */
|
237
|
+
/* for the profile-info command. */
|
238
|
+
/******************************************/
|
239
|
+
void ProfileInfoCommand(
|
240
|
+
Environment *theEnv,
|
241
|
+
UDFContext *context,
|
242
|
+
UDFValue *returnValue)
|
243
|
+
{
|
244
|
+
char buffer[512];
|
245
|
+
|
246
|
+
/*==================================*/
|
247
|
+
/* If code is still being profiled, */
|
248
|
+
/* update the profile end time. */
|
249
|
+
/*==================================*/
|
250
|
+
|
251
|
+
if (ProfileFunctionData(theEnv)->ProfileUserFunctions || ProfileFunctionData(theEnv)->ProfileConstructs)
|
252
|
+
{
|
253
|
+
ProfileFunctionData(theEnv)->ProfileEndTime = gentime();
|
254
|
+
ProfileFunctionData(theEnv)->ProfileTotalTime += (ProfileFunctionData(theEnv)->ProfileEndTime - ProfileFunctionData(theEnv)->ProfileStartTime);
|
255
|
+
}
|
256
|
+
|
257
|
+
/*==================================*/
|
258
|
+
/* Print the profiling information. */
|
259
|
+
/*==================================*/
|
260
|
+
|
261
|
+
if (ProfileFunctionData(theEnv)->LastProfileInfo != NO_PROFILE)
|
262
|
+
{
|
263
|
+
gensnprintf(buffer,sizeof(buffer),"Profile elapsed time = %g seconds\n",
|
264
|
+
ProfileFunctionData(theEnv)->ProfileTotalTime);
|
265
|
+
WriteString(theEnv,STDOUT,buffer);
|
266
|
+
|
267
|
+
if (ProfileFunctionData(theEnv)->LastProfileInfo == USER_FUNCTIONS)
|
268
|
+
{ WriteString(theEnv,STDOUT,"Function Name "); }
|
269
|
+
else if (ProfileFunctionData(theEnv)->LastProfileInfo == CONSTRUCTS_CODE)
|
270
|
+
{ WriteString(theEnv,STDOUT,"Construct Name "); }
|
271
|
+
|
272
|
+
WriteString(theEnv,STDOUT,"Entries Time % Time+Kids %+Kids\n");
|
273
|
+
|
274
|
+
if (ProfileFunctionData(theEnv)->LastProfileInfo == USER_FUNCTIONS)
|
275
|
+
{ WriteString(theEnv,STDOUT,"------------- "); }
|
276
|
+
else if (ProfileFunctionData(theEnv)->LastProfileInfo == CONSTRUCTS_CODE)
|
277
|
+
{ WriteString(theEnv,STDOUT,"-------------- "); }
|
278
|
+
|
279
|
+
WriteString(theEnv,STDOUT,"------- ------ ----- --------- ------\n");
|
280
|
+
}
|
281
|
+
|
282
|
+
if (ProfileFunctionData(theEnv)->LastProfileInfo == USER_FUNCTIONS) OutputUserFunctionsInfo(theEnv);
|
283
|
+
if (ProfileFunctionData(theEnv)->LastProfileInfo == CONSTRUCTS_CODE) OutputConstructsCodeInfo(theEnv);
|
284
|
+
}
|
285
|
+
|
286
|
+
/**********************************************/
|
287
|
+
/* StartProfile: Initiates bookkeeping needed */
|
288
|
+
/* to profile a construct or function. */
|
289
|
+
/**********************************************/
|
290
|
+
void StartProfile(
|
291
|
+
Environment *theEnv,
|
292
|
+
struct profileFrameInfo *theFrame,
|
293
|
+
struct userData **theList,
|
294
|
+
bool checkFlag)
|
295
|
+
{
|
296
|
+
double startTime, addTime;
|
297
|
+
struct constructProfileInfo *profileInfo;
|
298
|
+
|
299
|
+
if (! checkFlag)
|
300
|
+
{
|
301
|
+
theFrame->profileOnExit = false;
|
302
|
+
return;
|
303
|
+
}
|
304
|
+
|
305
|
+
profileInfo = (struct constructProfileInfo *) FetchUserData(theEnv,ProfileFunctionData(theEnv)->ProfileDataID,theList);
|
306
|
+
|
307
|
+
theFrame->profileOnExit = true;
|
308
|
+
theFrame->parentCall = false;
|
309
|
+
|
310
|
+
startTime = gentime();
|
311
|
+
theFrame->oldProfileFrame = ProfileFunctionData(theEnv)->ActiveProfileFrame;
|
312
|
+
|
313
|
+
if (ProfileFunctionData(theEnv)->ActiveProfileFrame != NULL)
|
314
|
+
{
|
315
|
+
addTime = startTime - ProfileFunctionData(theEnv)->ActiveProfileFrame->startTime;
|
316
|
+
ProfileFunctionData(theEnv)->ActiveProfileFrame->totalSelfTime += addTime;
|
317
|
+
}
|
318
|
+
|
319
|
+
ProfileFunctionData(theEnv)->ActiveProfileFrame = profileInfo;
|
320
|
+
|
321
|
+
ProfileFunctionData(theEnv)->ActiveProfileFrame->numberOfEntries++;
|
322
|
+
ProfileFunctionData(theEnv)->ActiveProfileFrame->startTime = startTime;
|
323
|
+
|
324
|
+
if (! ProfileFunctionData(theEnv)->ActiveProfileFrame->childCall)
|
325
|
+
{
|
326
|
+
theFrame->parentCall = true;
|
327
|
+
theFrame->parentStartTime = startTime;
|
328
|
+
ProfileFunctionData(theEnv)->ActiveProfileFrame->childCall = true;
|
329
|
+
}
|
330
|
+
}
|
331
|
+
|
332
|
+
/*******************************************/
|
333
|
+
/* EndProfile: Finishes bookkeeping needed */
|
334
|
+
/* to profile a construct or function. */
|
335
|
+
/*******************************************/
|
336
|
+
void EndProfile(
|
337
|
+
Environment *theEnv,
|
338
|
+
struct profileFrameInfo *theFrame)
|
339
|
+
{
|
340
|
+
double endTime, addTime;
|
341
|
+
|
342
|
+
if (! theFrame->profileOnExit) return;
|
343
|
+
|
344
|
+
endTime = gentime();
|
345
|
+
|
346
|
+
if (theFrame->parentCall)
|
347
|
+
{
|
348
|
+
addTime = endTime - theFrame->parentStartTime;
|
349
|
+
ProfileFunctionData(theEnv)->ActiveProfileFrame->totalWithChildrenTime += addTime;
|
350
|
+
ProfileFunctionData(theEnv)->ActiveProfileFrame->childCall = false;
|
351
|
+
}
|
352
|
+
|
353
|
+
ProfileFunctionData(theEnv)->ActiveProfileFrame->totalSelfTime += (endTime - ProfileFunctionData(theEnv)->ActiveProfileFrame->startTime);
|
354
|
+
|
355
|
+
if (theFrame->oldProfileFrame != NULL)
|
356
|
+
{ theFrame->oldProfileFrame->startTime = endTime; }
|
357
|
+
|
358
|
+
ProfileFunctionData(theEnv)->ActiveProfileFrame = theFrame->oldProfileFrame;
|
359
|
+
}
|
360
|
+
|
361
|
+
/******************************************/
|
362
|
+
/* OutputProfileInfo: Prints out a single */
|
363
|
+
/* line of profile information. */
|
364
|
+
/******************************************/
|
365
|
+
static bool OutputProfileInfo(
|
366
|
+
Environment *theEnv,
|
367
|
+
const char *itemName,
|
368
|
+
struct constructProfileInfo *profileInfo,
|
369
|
+
const char *printPrefixBefore,
|
370
|
+
const char *printPrefix,
|
371
|
+
const char *printPrefixAfter,
|
372
|
+
const char **banner)
|
373
|
+
{
|
374
|
+
double percent = 0.0, percentWithKids = 0.0;
|
375
|
+
char buffer[512];
|
376
|
+
|
377
|
+
if (profileInfo == NULL) return false;
|
378
|
+
|
379
|
+
if (profileInfo->numberOfEntries == 0) return false;
|
380
|
+
|
381
|
+
if (ProfileFunctionData(theEnv)->ProfileTotalTime != 0.0)
|
382
|
+
{
|
383
|
+
percent = (profileInfo->totalSelfTime * 100.0) / ProfileFunctionData(theEnv)->ProfileTotalTime;
|
384
|
+
if (percent < 0.005) percent = 0.0;
|
385
|
+
percentWithKids = (profileInfo->totalWithChildrenTime * 100.0) / ProfileFunctionData(theEnv)->ProfileTotalTime;
|
386
|
+
if (percentWithKids < 0.005) percentWithKids = 0.0;
|
387
|
+
}
|
388
|
+
|
389
|
+
if (percent < ProfileFunctionData(theEnv)->PercentThreshold) return false;
|
390
|
+
|
391
|
+
if ((banner != NULL) && (*banner != NULL))
|
392
|
+
{
|
393
|
+
WriteString(theEnv,STDOUT,*banner);
|
394
|
+
*banner = NULL;
|
395
|
+
}
|
396
|
+
|
397
|
+
if (printPrefixBefore != NULL)
|
398
|
+
{ WriteString(theEnv,STDOUT,printPrefixBefore); }
|
399
|
+
|
400
|
+
if (printPrefix != NULL)
|
401
|
+
{ WriteString(theEnv,STDOUT,printPrefix); }
|
402
|
+
|
403
|
+
if (printPrefixAfter != NULL)
|
404
|
+
{ WriteString(theEnv,STDOUT,printPrefixAfter); }
|
405
|
+
|
406
|
+
if (strlen(itemName) >= 40)
|
407
|
+
{
|
408
|
+
WriteString(theEnv,STDOUT,itemName);
|
409
|
+
WriteString(theEnv,STDOUT,"\n");
|
410
|
+
itemName = "";
|
411
|
+
}
|
412
|
+
|
413
|
+
gensnprintf(buffer,sizeof(buffer),ProfileFunctionData(theEnv)->OutputString,
|
414
|
+
itemName,
|
415
|
+
(long) profileInfo->numberOfEntries,
|
416
|
+
|
417
|
+
(double) profileInfo->totalSelfTime,
|
418
|
+
(double) percent,
|
419
|
+
|
420
|
+
(double) profileInfo->totalWithChildrenTime,
|
421
|
+
(double) percentWithKids);
|
422
|
+
WriteString(theEnv,STDOUT,buffer);
|
423
|
+
|
424
|
+
return true;
|
425
|
+
}
|
426
|
+
|
427
|
+
/*******************************************/
|
428
|
+
/* ProfileResetCommand: H/L access routine */
|
429
|
+
/* for the profile-reset command. */
|
430
|
+
/*******************************************/
|
431
|
+
void ProfileResetCommand(
|
432
|
+
Environment *theEnv,
|
433
|
+
UDFContext *context,
|
434
|
+
UDFValue *returnValue)
|
435
|
+
{
|
436
|
+
struct functionDefinition *theFunction;
|
437
|
+
int i;
|
438
|
+
#if DEFFUNCTION_CONSTRUCT
|
439
|
+
Deffunction *theDeffunction;
|
440
|
+
#endif
|
441
|
+
#if DEFRULE_CONSTRUCT
|
442
|
+
Defrule *theDefrule;
|
443
|
+
#endif
|
444
|
+
#if DEFGENERIC_CONSTRUCT
|
445
|
+
Defgeneric *theDefgeneric;
|
446
|
+
unsigned short methodIndex;
|
447
|
+
Defmethod *theMethod;
|
448
|
+
#endif
|
449
|
+
#if OBJECT_SYSTEM
|
450
|
+
Defclass *theDefclass;
|
451
|
+
DefmessageHandler *theHandler;
|
452
|
+
unsigned handlerIndex;
|
453
|
+
#endif
|
454
|
+
|
455
|
+
ProfileFunctionData(theEnv)->ProfileStartTime = 0.0;
|
456
|
+
ProfileFunctionData(theEnv)->ProfileEndTime = 0.0;
|
457
|
+
ProfileFunctionData(theEnv)->ProfileTotalTime = 0.0;
|
458
|
+
ProfileFunctionData(theEnv)->LastProfileInfo = NO_PROFILE;
|
459
|
+
|
460
|
+
for (theFunction = GetFunctionList(theEnv);
|
461
|
+
theFunction != NULL;
|
462
|
+
theFunction = theFunction->next)
|
463
|
+
{
|
464
|
+
ResetProfileInfo((struct constructProfileInfo *)
|
465
|
+
TestUserData(ProfileFunctionData(theEnv)->ProfileDataID,theFunction->usrData));
|
466
|
+
}
|
467
|
+
|
468
|
+
for (i = 0; i < MAXIMUM_PRIMITIVES; i++)
|
469
|
+
{
|
470
|
+
if (EvaluationData(theEnv)->PrimitivesArray[i] != NULL)
|
471
|
+
{
|
472
|
+
ResetProfileInfo((struct constructProfileInfo *)
|
473
|
+
TestUserData(ProfileFunctionData(theEnv)->ProfileDataID,EvaluationData(theEnv)->PrimitivesArray[i]->usrData));
|
474
|
+
}
|
475
|
+
}
|
476
|
+
|
477
|
+
#if DEFFUNCTION_CONSTRUCT
|
478
|
+
for (theDeffunction = GetNextDeffunction(theEnv,NULL);
|
479
|
+
theDeffunction != NULL;
|
480
|
+
theDeffunction = GetNextDeffunction(theEnv,theDeffunction))
|
481
|
+
{
|
482
|
+
ResetProfileInfo((struct constructProfileInfo *)
|
483
|
+
TestUserData(ProfileFunctionData(theEnv)->ProfileDataID,theDeffunction->header.usrData));
|
484
|
+
}
|
485
|
+
#endif
|
486
|
+
|
487
|
+
#if DEFRULE_CONSTRUCT
|
488
|
+
for (theDefrule = GetNextDefrule(theEnv,NULL);
|
489
|
+
theDefrule != NULL;
|
490
|
+
theDefrule = GetNextDefrule(theEnv,theDefrule))
|
491
|
+
{
|
492
|
+
ResetProfileInfo((struct constructProfileInfo *)
|
493
|
+
TestUserData(ProfileFunctionData(theEnv)->ProfileDataID,theDefrule->header.usrData));
|
494
|
+
}
|
495
|
+
#endif
|
496
|
+
|
497
|
+
#if DEFGENERIC_CONSTRUCT
|
498
|
+
for (theDefgeneric = GetNextDefgeneric(theEnv,NULL);
|
499
|
+
theDefgeneric != NULL;
|
500
|
+
theDefgeneric = GetNextDefgeneric(theEnv,theDefgeneric))
|
501
|
+
{
|
502
|
+
ResetProfileInfo((struct constructProfileInfo *)
|
503
|
+
TestUserData(ProfileFunctionData(theEnv)->ProfileDataID,theDefgeneric->header.usrData));
|
504
|
+
|
505
|
+
for (methodIndex = GetNextDefmethod(theDefgeneric,0);
|
506
|
+
methodIndex != 0;
|
507
|
+
methodIndex = GetNextDefmethod(theDefgeneric,methodIndex))
|
508
|
+
{
|
509
|
+
theMethod = GetDefmethodPointer(theDefgeneric,methodIndex);
|
510
|
+
ResetProfileInfo((struct constructProfileInfo *)
|
511
|
+
TestUserData(ProfileFunctionData(theEnv)->ProfileDataID,theMethod->header.usrData));
|
512
|
+
}
|
513
|
+
}
|
514
|
+
#endif
|
515
|
+
|
516
|
+
#if OBJECT_SYSTEM
|
517
|
+
for (theDefclass = GetNextDefclass(theEnv,NULL);
|
518
|
+
theDefclass != NULL;
|
519
|
+
theDefclass = GetNextDefclass(theEnv,theDefclass))
|
520
|
+
{
|
521
|
+
ResetProfileInfo((struct constructProfileInfo *)
|
522
|
+
TestUserData(ProfileFunctionData(theEnv)->ProfileDataID,theDefclass->header.usrData));
|
523
|
+
for (handlerIndex = GetNextDefmessageHandler(theDefclass,0);
|
524
|
+
handlerIndex != 0;
|
525
|
+
handlerIndex = GetNextDefmessageHandler(theDefclass,handlerIndex))
|
526
|
+
{
|
527
|
+
theHandler = GetDefmessageHandlerPointer(theDefclass,handlerIndex);
|
528
|
+
ResetProfileInfo((struct constructProfileInfo *)
|
529
|
+
TestUserData(ProfileFunctionData(theEnv)->ProfileDataID,theHandler->header.usrData));
|
530
|
+
}
|
531
|
+
}
|
532
|
+
#endif
|
533
|
+
|
534
|
+
}
|
535
|
+
|
536
|
+
/*************************************************/
|
537
|
+
/* ResetProfileInfo: Sets the initial values for */
|
538
|
+
/* a constructProfileInfo data structure. */
|
539
|
+
/*************************************************/
|
540
|
+
void ResetProfileInfo(
|
541
|
+
struct constructProfileInfo *profileInfo)
|
542
|
+
{
|
543
|
+
if (profileInfo == NULL) return;
|
544
|
+
|
545
|
+
profileInfo->numberOfEntries = 0;
|
546
|
+
profileInfo->childCall = false;
|
547
|
+
profileInfo->startTime = 0.0;
|
548
|
+
profileInfo->totalSelfTime = 0.0;
|
549
|
+
profileInfo->totalWithChildrenTime = 0.0;
|
550
|
+
}
|
551
|
+
|
552
|
+
/****************************/
|
553
|
+
/* OutputUserFunctionsInfo: */
|
554
|
+
/****************************/
|
555
|
+
static void OutputUserFunctionsInfo(
|
556
|
+
Environment *theEnv)
|
557
|
+
{
|
558
|
+
struct functionDefinition *theFunction;
|
559
|
+
int i;
|
560
|
+
|
561
|
+
for (theFunction = GetFunctionList(theEnv);
|
562
|
+
theFunction != NULL;
|
563
|
+
theFunction = theFunction->next)
|
564
|
+
{
|
565
|
+
OutputProfileInfo(theEnv,theFunction->callFunctionName->contents,
|
566
|
+
(struct constructProfileInfo *)
|
567
|
+
TestUserData(ProfileFunctionData(theEnv)->ProfileDataID,
|
568
|
+
theFunction->usrData),
|
569
|
+
NULL,NULL,NULL,NULL);
|
570
|
+
}
|
571
|
+
|
572
|
+
for (i = 0; i < MAXIMUM_PRIMITIVES; i++)
|
573
|
+
{
|
574
|
+
if (EvaluationData(theEnv)->PrimitivesArray[i] != NULL)
|
575
|
+
{
|
576
|
+
OutputProfileInfo(theEnv,EvaluationData(theEnv)->PrimitivesArray[i]->name,
|
577
|
+
(struct constructProfileInfo *)
|
578
|
+
TestUserData(ProfileFunctionData(theEnv)->ProfileDataID,
|
579
|
+
EvaluationData(theEnv)->PrimitivesArray[i]->usrData),
|
580
|
+
NULL,NULL,NULL,NULL);
|
581
|
+
}
|
582
|
+
}
|
583
|
+
}
|
584
|
+
|
585
|
+
/*****************************/
|
586
|
+
/* OutputConstructsCodeInfo: */
|
587
|
+
/*****************************/
|
588
|
+
static void OutputConstructsCodeInfo(
|
589
|
+
Environment *theEnv)
|
590
|
+
{
|
591
|
+
#if (! DEFFUNCTION_CONSTRUCT) && (! DEFGENERIC_CONSTRUCT) && (! OBJECT_SYSTEM) && (! DEFRULE_CONSTRUCT)
|
592
|
+
#pragma unused(theEnv)
|
593
|
+
#endif
|
594
|
+
#if DEFFUNCTION_CONSTRUCT
|
595
|
+
Deffunction *theDeffunction;
|
596
|
+
#endif
|
597
|
+
#if DEFRULE_CONSTRUCT
|
598
|
+
Defrule *theDefrule;
|
599
|
+
#endif
|
600
|
+
#if DEFGENERIC_CONSTRUCT
|
601
|
+
Defgeneric *theDefgeneric;
|
602
|
+
Defmethod *theMethod;
|
603
|
+
unsigned short methodIndex;
|
604
|
+
StringBuilder *theSB;
|
605
|
+
#endif
|
606
|
+
#if OBJECT_SYSTEM
|
607
|
+
Defclass *theDefclass;
|
608
|
+
DefmessageHandler *theHandler;
|
609
|
+
unsigned handlerIndex;
|
610
|
+
#endif
|
611
|
+
#if DEFGENERIC_CONSTRUCT || OBJECT_SYSTEM
|
612
|
+
const char *prefix, *prefixBefore, *prefixAfter;
|
613
|
+
#endif
|
614
|
+
const char *banner;
|
615
|
+
|
616
|
+
banner = "\n*** Deffunctions ***\n\n";
|
617
|
+
|
618
|
+
#if DEFFUNCTION_CONSTRUCT
|
619
|
+
for (theDeffunction = GetNextDeffunction(theEnv,NULL);
|
620
|
+
theDeffunction != NULL;
|
621
|
+
theDeffunction = GetNextDeffunction(theEnv,theDeffunction))
|
622
|
+
{
|
623
|
+
OutputProfileInfo(theEnv,DeffunctionName(theDeffunction),
|
624
|
+
(struct constructProfileInfo *)
|
625
|
+
TestUserData(ProfileFunctionData(theEnv)->ProfileDataID,theDeffunction->header.usrData),
|
626
|
+
NULL,NULL,NULL,&banner);
|
627
|
+
}
|
628
|
+
#endif
|
629
|
+
|
630
|
+
banner = "\n*** Defgenerics ***\n";
|
631
|
+
#if DEFGENERIC_CONSTRUCT
|
632
|
+
theSB = CreateStringBuilder(theEnv,512);
|
633
|
+
for (theDefgeneric = GetNextDefgeneric(theEnv,NULL);
|
634
|
+
theDefgeneric != NULL;
|
635
|
+
theDefgeneric = GetNextDefgeneric(theEnv,theDefgeneric))
|
636
|
+
{
|
637
|
+
prefixBefore = "\n";
|
638
|
+
prefix = DefgenericName(theDefgeneric);
|
639
|
+
prefixAfter = "\n";
|
640
|
+
|
641
|
+
for (methodIndex = GetNextDefmethod(theDefgeneric,0);
|
642
|
+
methodIndex != 0;
|
643
|
+
methodIndex = GetNextDefmethod(theDefgeneric,methodIndex))
|
644
|
+
{
|
645
|
+
theMethod = GetDefmethodPointer(theDefgeneric,methodIndex);
|
646
|
+
|
647
|
+
DefmethodDescription(theDefgeneric,methodIndex,theSB);
|
648
|
+
if (OutputProfileInfo(theEnv,theSB->contents,
|
649
|
+
(struct constructProfileInfo *)
|
650
|
+
TestUserData(ProfileFunctionData(theEnv)->ProfileDataID,theMethod->header.usrData),
|
651
|
+
prefixBefore,prefix,prefixAfter,&banner))
|
652
|
+
{
|
653
|
+
prefixBefore = NULL;
|
654
|
+
prefix = NULL;
|
655
|
+
prefixAfter = NULL;
|
656
|
+
}
|
657
|
+
}
|
658
|
+
}
|
659
|
+
SBDispose(theSB);
|
660
|
+
#endif
|
661
|
+
|
662
|
+
banner = "\n*** Defclasses ***\n";
|
663
|
+
#if OBJECT_SYSTEM
|
664
|
+
for (theDefclass = GetNextDefclass(theEnv,NULL);
|
665
|
+
theDefclass != NULL;
|
666
|
+
theDefclass = GetNextDefclass(theEnv,theDefclass))
|
667
|
+
{
|
668
|
+
prefixAfter = "\n";
|
669
|
+
prefix = DefclassName(theDefclass);
|
670
|
+
prefixBefore = "\n";
|
671
|
+
|
672
|
+
for (handlerIndex = GetNextDefmessageHandler(theDefclass,0);
|
673
|
+
handlerIndex != 0;
|
674
|
+
handlerIndex = GetNextDefmessageHandler(theDefclass,handlerIndex))
|
675
|
+
{
|
676
|
+
theHandler = GetDefmessageHandlerPointer(theDefclass,handlerIndex);
|
677
|
+
if (OutputProfileInfo(theEnv,DefmessageHandlerName(theDefclass,handlerIndex),
|
678
|
+
(struct constructProfileInfo *)
|
679
|
+
TestUserData(ProfileFunctionData(theEnv)->ProfileDataID,
|
680
|
+
theHandler->header.usrData),
|
681
|
+
prefixBefore,prefix,prefixAfter,&banner))
|
682
|
+
{
|
683
|
+
prefixBefore = NULL;
|
684
|
+
prefix = NULL;
|
685
|
+
prefixAfter = NULL;
|
686
|
+
}
|
687
|
+
}
|
688
|
+
|
689
|
+
}
|
690
|
+
#endif
|
691
|
+
|
692
|
+
banner = "\n*** Defrules ***\n\n";
|
693
|
+
|
694
|
+
#if DEFRULE_CONSTRUCT
|
695
|
+
for (theDefrule = GetNextDefrule(theEnv,NULL);
|
696
|
+
theDefrule != NULL;
|
697
|
+
theDefrule = GetNextDefrule(theEnv,theDefrule))
|
698
|
+
{
|
699
|
+
OutputProfileInfo(theEnv,DefruleName(theDefrule),
|
700
|
+
(struct constructProfileInfo *)
|
701
|
+
TestUserData(ProfileFunctionData(theEnv)->ProfileDataID,theDefrule->header.usrData),
|
702
|
+
NULL,NULL,NULL,&banner);
|
703
|
+
}
|
704
|
+
#endif
|
705
|
+
|
706
|
+
}
|
707
|
+
|
708
|
+
/*********************************************************/
|
709
|
+
/* SetProfilePercentThresholdCommand: H/L access routine */
|
710
|
+
/* for the set-profile-percent-threshold command. */
|
711
|
+
/*********************************************************/
|
712
|
+
void SetProfilePercentThresholdCommand(
|
713
|
+
Environment *theEnv,
|
714
|
+
UDFContext *context,
|
715
|
+
UDFValue *returnValue)
|
716
|
+
{
|
717
|
+
UDFValue theValue;
|
718
|
+
double newThreshold;
|
719
|
+
|
720
|
+
if (! UDFFirstArgument(context,NUMBER_BITS,&theValue))
|
721
|
+
{ return; }
|
722
|
+
|
723
|
+
newThreshold = CVCoerceToFloat(&theValue);
|
724
|
+
|
725
|
+
if ((newThreshold < 0.0) || (newThreshold > 100.0))
|
726
|
+
{
|
727
|
+
UDFInvalidArgumentMessage(context,"number in the range 0 to 100");
|
728
|
+
returnValue->floatValue = CreateFloat(theEnv,-1.0);
|
729
|
+
}
|
730
|
+
else
|
731
|
+
{ returnValue->floatValue = CreateFloat(theEnv,SetProfilePercentThreshold(theEnv,newThreshold)); }
|
732
|
+
}
|
733
|
+
|
734
|
+
/****************************************************/
|
735
|
+
/* SetProfilePercentThreshold: C access routine for */
|
736
|
+
/* the set-profile-percent-threshold command. */
|
737
|
+
/****************************************************/
|
738
|
+
double SetProfilePercentThreshold(
|
739
|
+
Environment *theEnv,
|
740
|
+
double value)
|
741
|
+
{
|
742
|
+
double oldPercentThreshhold;
|
743
|
+
|
744
|
+
if ((value < 0.0) || (value > 100.0))
|
745
|
+
{ return(-1.0); }
|
746
|
+
|
747
|
+
oldPercentThreshhold = ProfileFunctionData(theEnv)->PercentThreshold;
|
748
|
+
|
749
|
+
ProfileFunctionData(theEnv)->PercentThreshold = value;
|
750
|
+
|
751
|
+
return(oldPercentThreshhold);
|
752
|
+
}
|
753
|
+
|
754
|
+
/*********************************************************/
|
755
|
+
/* GetProfilePercentThresholdCommand: H/L access routine */
|
756
|
+
/* for the get-profile-percent-threshold command. */
|
757
|
+
/*********************************************************/
|
758
|
+
void GetProfilePercentThresholdCommand(
|
759
|
+
Environment *theEnv,
|
760
|
+
UDFContext *context,
|
761
|
+
UDFValue *returnValue)
|
762
|
+
{
|
763
|
+
returnValue->floatValue = CreateFloat(theEnv,ProfileFunctionData(theEnv)->PercentThreshold);
|
764
|
+
}
|
765
|
+
|
766
|
+
/****************************************************/
|
767
|
+
/* GetProfilePercentThreshold: C access routine for */
|
768
|
+
/* the get-profile-percent-threshold command. */
|
769
|
+
/****************************************************/
|
770
|
+
double GetProfilePercentThreshold(
|
771
|
+
Environment *theEnv)
|
772
|
+
{
|
773
|
+
return(ProfileFunctionData(theEnv)->PercentThreshold);
|
774
|
+
}
|
775
|
+
|
776
|
+
/**********************************************************/
|
777
|
+
/* SetProfileOutputString: Sets the output string global. */
|
778
|
+
/**********************************************************/
|
779
|
+
const char *SetProfileOutputString(
|
780
|
+
Environment *theEnv,
|
781
|
+
const char *value)
|
782
|
+
{
|
783
|
+
const char *oldOutputString;
|
784
|
+
|
785
|
+
if (value == NULL)
|
786
|
+
{ return(ProfileFunctionData(theEnv)->OutputString); }
|
787
|
+
|
788
|
+
oldOutputString = ProfileFunctionData(theEnv)->OutputString;
|
789
|
+
|
790
|
+
ProfileFunctionData(theEnv)->OutputString = value;
|
791
|
+
|
792
|
+
return(oldOutputString);
|
793
|
+
}
|
794
|
+
|
795
|
+
#if (! RUN_TIME)
|
796
|
+
/******************************************************************/
|
797
|
+
/* ProfileClearFunction: Profiling clear routine for use with the */
|
798
|
+
/* clear command. Removes user data attached to user functions. */
|
799
|
+
/******************************************************************/
|
800
|
+
static void ProfileClearFunction(
|
801
|
+
Environment *theEnv,
|
802
|
+
void *context)
|
803
|
+
{
|
804
|
+
struct functionDefinition *theFunction;
|
805
|
+
int i;
|
806
|
+
|
807
|
+
for (theFunction = GetFunctionList(theEnv);
|
808
|
+
theFunction != NULL;
|
809
|
+
theFunction = theFunction->next)
|
810
|
+
{
|
811
|
+
theFunction->usrData =
|
812
|
+
DeleteUserData(theEnv,ProfileFunctionData(theEnv)->ProfileDataID,theFunction->usrData);
|
813
|
+
}
|
814
|
+
|
815
|
+
for (i = 0; i < MAXIMUM_PRIMITIVES; i++)
|
816
|
+
{
|
817
|
+
if (EvaluationData(theEnv)->PrimitivesArray[i] != NULL)
|
818
|
+
{
|
819
|
+
EvaluationData(theEnv)->PrimitivesArray[i]->usrData =
|
820
|
+
DeleteUserData(theEnv,ProfileFunctionData(theEnv)->ProfileDataID,EvaluationData(theEnv)->PrimitivesArray[i]->usrData);
|
821
|
+
}
|
822
|
+
}
|
823
|
+
}
|
824
|
+
#endif
|
825
|
+
|
826
|
+
#endif /* PROFILING_FUNCTIONS */
|
827
|
+
|