summaryrefslogtreecommitdiff
path: root/ipl/mprogs/cvtsum.icn
blob: 9e6dfc84ed189e7785731999765693af05473bd7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
############################################################################
#
#	File:     cvtsum.icn
#
#	Subject:  Program to count conversion event tuples
#
#	Author:   Ralph E. Griswold
#
#	Date:     November 25, 1996
#
############################################################################
#
#  This file is in the public domain.
#
############################################################################
#
#  This program counts conversion events that occur during the monitoring
#  of Icon program execution.
#
############################################################################
#
#  Requires:  MT Icon and event monitoring
#
############################################################################
#
#  Includes:  evdefs.icn
#
############################################################################

link evinit
link numbers
link typecode

$include "evdefs.icn"

procedure main(args)
   local counts, total, futile, triple, target, value, failure

   EvInit(args)

   counts := table(0)
   total := -1			# account for first vacuous entry
   futile := 0
   failure := 0

   while EvGet(ConvMask) do
      case &eventcode of {
         E_Aconv:   {
            total +:= 1
            if total % 1000 = 0 then writes(&errout, ".")
            counts[triple] +:= 1
            target := typecode(&eventvalue)
            triple := target
            }
         E_Tconv:   {
            value := typecode(&eventvalue)
            if value == target then futile +:= 1
            triple ||:= value
            }
         E_Nconv:   triple ||:= " S"
         E_Sconv:   triple ||:= " S"
         E_Fconv:   {
            failure +:= 1
            triple ||:= " F"
            }
         default:   stop("*** illegal event code")
         }

   delete(counts,&null)

   counts := sort(counts, 3)

   while write(get(counts), right(get(counts),6))

   write("\ntotal = ",total,"\n")
   write(fix(futile / real(total), .01, 3, 2),"% futile")
   write(fix(failure / real(total), .01, 3, 2),"% failed")

end