home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / historic / v941.tgz / icon.v941src.tar / icon.v941src / ipl / mprogs / cvtsum.icn < prev    next >
Text File  |  2000-07-29  |  2KB  |  80 lines

  1. ############################################################################
  2. #
  3. #    File:     cvtsum.icn
  4. #
  5. #    Subject:  Program to count conversion event tuples
  6. #
  7. #    Author:   Ralph E. Griswold
  8. #
  9. #    Date:     November 25, 1996
  10. #
  11. ############################################################################
  12. #
  13. #  This file is in the public domain.
  14. #
  15. ############################################################################
  16. #
  17. #  This program counts conversion events that occur during the monitoring
  18. #  of Icon program execution.
  19. #
  20. ############################################################################
  21. #
  22. #  Requires:  MT Icon and event monitoring
  23. #
  24. ############################################################################
  25. #
  26. #  Includes:  evdefs.icn
  27. #
  28. ############################################################################
  29.  
  30. link evinit
  31. link numbers
  32. link typecode
  33.  
  34. $include "evdefs.icn"
  35.  
  36. procedure main(args)
  37.    local counts, total, futile, triple, target, value, failure
  38.  
  39.    EvInit(args)
  40.  
  41.    counts := table(0)
  42.    total := -1            # account for first vacuous entry
  43.    futile := 0
  44.    failure := 0
  45.  
  46.    while EvGet(ConvMask) do
  47.       case &eventcode of {
  48.          E_Aconv:   {
  49.             total +:= 1
  50.             if total % 1000 = 0 then writes(&errout, ".")
  51.             counts[triple] +:= 1
  52.             target := typecode(&eventvalue)
  53.             triple := target
  54.             }
  55.          E_Tconv:   {
  56.             value := typecode(&eventvalue)
  57.             if value == target then futile +:= 1
  58.             triple ||:= value
  59.             }
  60.          E_Nconv:   triple ||:= " S"
  61.          E_Sconv:   triple ||:= " S"
  62.          E_Fconv:   {
  63.             failure +:= 1
  64.             triple ||:= " F"
  65.             }
  66.          default:   stop("*** illegal event code")
  67.          }
  68.  
  69.    delete(counts,&null)
  70.  
  71.    counts := sort(counts, 3)
  72.  
  73.    while write(get(counts), right(get(counts),6))
  74.  
  75.    write("\ntotal = ",total,"\n")
  76.    write(fix(futile / real(total), .01, 3, 2),"% futile")
  77.    write(fix(failure / real(total), .01, 3, 2),"% failed")
  78.  
  79. end
  80.