13 |
13 |
14 Object subclass:#MessageTracer |
14 Object subclass:#MessageTracer |
15 instanceVariableNames:'traceDetail tracedBlock' |
15 instanceVariableNames:'traceDetail tracedBlock' |
16 classVariableNames:'BreakpointSignal CallingLevel BreakBlock TraceSenderBlock |
16 classVariableNames:'BreakpointSignal CallingLevel BreakBlock TraceSenderBlock |
17 TraceSenderBlock2 LeaveBreakBlock LeaveTraceBlock MethodCounts |
17 TraceSenderBlock2 LeaveBreakBlock LeaveTraceBlock MethodCounts |
18 MethodMemoryUsage MethodTiming TraceFullBlock TraceFullBlock2 |
18 MethodCountsPerReceiverClass MethodMemoryUsage MethodTiming |
19 ObjectWrittenBreakpointSignal ObjectCopyHolders TimeForWrappers' |
19 TraceFullBlock TraceFullBlock2 ObjectWrittenBreakpointSignal |
|
20 ObjectCopyHolders TimeForWrappers' |
20 poolDictionaries:'' |
21 poolDictionaries:'' |
21 category:'System-Debugging-Support' |
22 category:'System-Debugging-Support' |
22 ! |
23 ! |
23 |
24 |
24 MessageTracer subclass:#InteractionCollector |
25 MessageTracer subclass:#InteractionCollector |
888 |
889 |
889 "Created: / 15.12.1995 / 10:57:49 / cg" |
890 "Created: / 15.12.1995 / 10:57:49 / cg" |
890 "Modified: / 27.7.1998 / 10:47:46 / cg" |
891 "Modified: / 27.7.1998 / 10:47:46 / cg" |
891 ! |
892 ! |
892 |
893 |
|
894 countMethodByReceiverClass:aMethod |
|
895 "arrange for a aMethod's execution to be counted and maintain |
|
896 a per-receiver class profile. |
|
897 Use unwrapMethod to remove this." |
|
898 |
|
899 MethodCountsPerReceiverClass isNil ifTrue:[ |
|
900 MethodCountsPerReceiverClass := IdentityDictionary new. |
|
901 ]. |
|
902 MethodCountsPerReceiverClass at:aMethod put:(IdentityDictionary new). |
|
903 |
|
904 ^ self wrapMethod:aMethod |
|
905 onEntry:[:con | |
|
906 |cls perMethodCounts cnt| |
|
907 |
|
908 cls := (con receiver class). |
|
909 perMethodCounts := MethodCountsPerReceiverClass at:aMethod. |
|
910 cnt := perMethodCounts at:cls ifAbsentPut:0. |
|
911 perMethodCounts at:cls put:(cnt + 1). |
|
912 MessageTracer changed:#statistics: with:aMethod. |
|
913 aMethod changed:#statistics |
|
914 ] |
|
915 onExit:[:con :retVal | |
|
916 ] |
|
917 |
|
918 " |
|
919 MessageTracer countMethodWithReceiverStatistic:(Collection compiledMethodAt:#detect:). |
|
920 NewSystemBrowser open. |
|
921 MessageTracer executionCountsOf:(Collection compiledMethodAt:#detect:) printNL. |
|
922 MessageTracer stopCountingMethod:(Collection compiledMethodAt:#detect:) |
|
923 " |
|
924 ! |
|
925 |
893 executionCountOfMethod:aMethod |
926 executionCountOfMethod:aMethod |
894 "return the current count" |
927 "return the current count" |
895 |
928 |
896 |count| |
929 |count counts| |
897 |
930 |
898 MethodCounts isNil ifTrue:[^ 0]. |
931 MethodCounts notNil ifTrue:[ |
899 aMethod isWrapped ifTrue:[ |
932 aMethod isWrapped ifTrue:[ |
900 count := MethodCounts at:aMethod originalMethod ifAbsent:nil. |
933 count := MethodCounts at:aMethod originalMethod ifAbsent:nil. |
901 count notNil ifTrue:[^ count]. |
934 count notNil ifTrue:[^ count]. |
902 ]. |
935 ]. |
903 ^ MethodCounts at:aMethod ifAbsent:0 |
936 ^ MethodCounts at:aMethod ifAbsent:0 |
904 |
937 ]. |
905 "Created: 15.12.1995 / 11:01:56 / cg" |
938 MethodCountsPerReceiverClass notNil ifTrue:[ |
906 "Modified: 15.12.1995 / 15:45:15 / cg" |
939 aMethod isWrapped ifTrue:[ |
|
940 counts := MethodCountsPerReceiverClass at:aMethod originalMethod ifAbsent:nil. |
|
941 ]. |
|
942 counts isNil ifTrue:[ |
|
943 counts := MethodCounts at:aMethod ifAbsent:#(). |
|
944 ]. |
|
945 ^ (counts collect:[:eachClassCountAssoc | eachClassCountAssoc value]) sum |
|
946 ]. |
|
947 ^ 0 |
|
948 ! |
|
949 |
|
950 executionCountsByReceiverClassOfMethod:aMethod |
|
951 "return a collection mapping receiver class to call counts" |
|
952 |
|
953 |counts| |
|
954 |
|
955 MethodCountsPerReceiverClass notNil ifTrue:[ |
|
956 aMethod isWrapped ifTrue:[ |
|
957 counts := MethodCountsPerReceiverClass at:aMethod originalMethod ifAbsent:nil. |
|
958 ]. |
|
959 counts isNil ifTrue:[ |
|
960 counts := MethodCounts at:aMethod ifAbsent:#(). |
|
961 ]. |
|
962 ^ counts |
|
963 ]. |
|
964 ^ #() |
907 ! |
965 ! |
908 |
966 |
909 resetCountOfMethod:aMethod |
967 resetCountOfMethod:aMethod |
910 "return the current count" |
968 "return the current count" |
911 |
969 |
922 "remove counting of aMethod" |
980 "remove counting of aMethod" |
923 |
981 |
924 MethodCounts notNil ifTrue:[ |
982 MethodCounts notNil ifTrue:[ |
925 aMethod isWrapped ifTrue:[ |
983 aMethod isWrapped ifTrue:[ |
926 MethodCounts removeKey:aMethod originalMethod ifAbsent:nil. |
984 MethodCounts removeKey:aMethod originalMethod ifAbsent:nil. |
|
985 ]. |
|
986 ]. |
|
987 MethodCountsPerReceiverClass notNil ifTrue:[ |
|
988 aMethod isWrapped ifTrue:[ |
|
989 MethodCountsPerReceiverClass removeKey:aMethod originalMethod ifAbsent:nil. |
927 ]. |
990 ]. |
928 ]. |
991 ]. |
929 ^ self unwrapMethod:aMethod |
992 ^ self unwrapMethod:aMethod |
930 |
993 |
931 "Modified: 15.12.1995 / 15:43:53 / cg" |
994 "Modified: 15.12.1995 / 15:43:53 / cg" |
2742 ! |
2805 ! |
2743 |
2806 |
2744 isCounting:aMethod |
2807 isCounting:aMethod |
2745 "return true if aMethod is counted" |
2808 "return true if aMethod is counted" |
2746 |
2809 |
2747 MethodCounts isNil ifTrue:[^ false]. |
2810 MethodCounts notNil ifTrue:[ |
2748 (MethodCounts includesKey:aMethod) ifTrue:[^ true]. |
2811 (MethodCounts includesKey:aMethod) ifTrue:[^ true]. |
2749 aMethod isWrapped ifTrue:[ |
2812 aMethod isWrapped ifTrue:[ |
2750 ^ MethodCounts includesKey:aMethod originalMethod |
2813 (MethodCounts includesKey:aMethod originalMethod)ifTrue:[^ true]. |
|
2814 ]. |
|
2815 ]. |
|
2816 MethodCountsPerReceiverClass notNil ifTrue:[ |
|
2817 (MethodCountsPerReceiverClass includesKey:aMethod) ifTrue:[^ true]. |
|
2818 aMethod isWrapped ifTrue:[ |
|
2819 (MethodCountsPerReceiverClass includesKey:aMethod originalMethod)ifTrue:[^ true]. |
|
2820 ]. |
2751 ]. |
2821 ]. |
2752 ^ false |
2822 ^ false |
2753 |
2823 |
2754 "Created: 15.12.1995 / 11:07:58 / cg" |
2824 "Created: 15.12.1995 / 11:07:58 / cg" |
2755 "Modified: 15.12.1995 / 15:42:10 / cg" |
2825 "Modified: 15.12.1995 / 15:42:10 / cg" |
|
2826 ! |
|
2827 |
|
2828 isCountingByReceiverClass:aMethod |
|
2829 "return true if aMethod is counted with per receiver class statistics" |
|
2830 |
|
2831 MethodCountsPerReceiverClass isNil ifTrue:[^ false]. |
|
2832 (MethodCountsPerReceiverClass includesKey:aMethod) ifTrue:[^ true]. |
|
2833 aMethod isWrapped ifTrue:[ |
|
2834 ^ MethodCountsPerReceiverClass includesKey:aMethod originalMethod |
|
2835 ]. |
|
2836 ^ false |
2756 ! |
2837 ! |
2757 |
2838 |
2758 isTiming:aMethod |
2839 isTiming:aMethod |
2759 "return true if aMethod is timed" |
2840 "return true if aMethod is timed" |
2760 |
2841 |