home *** CD-ROM | disk | FTP | other *** search
/ Phoenix CD 2.0 / Phoenix_CD.cdr / 24b / kcount.zip / KCOUNT.DOC < prev   
Text File  |  1986-11-01  |  17KB  |  442 lines

  1. KCOUNT V1.10 (C)Copyright Graeme W. McRae, November 1, 1986    Page 1
  2.  
  3.  
  4. KCOUNT Keywords
  5.  
  6. TSR KEYBOARD USAGE ACTIVITY CPU TIME MEASUREMENT MONITOR
  7.  
  8.  
  9. KCOUNT Introduction
  10.  
  11. KCOUNT V1.10 is a small (4k) resident program that measures the
  12. percentage of "active" PC usage by monitoring the keyboard
  13. interrupt.  It is offered free -- this is not shareware. It can
  14. write monitor reports to a file, and can be used in a CED SYN or
  15. .BAT file to automate statistics collection.  Source avail. on
  16. request. 1k bytes stay resident.  Self-removable.  Online help.
  17. (C)Graeme W. McRae 1986 [73307,2453]
  18.  
  19. The motivation for writing this program was the desire to
  20. determine whether or not a PC is being used, and at what
  21. level of activity.  Various schemes were suggested to measure the
  22. "CPU activity" of the 8088.  The trouble with these schemes is
  23. that many programs loop continously when they are idle.  This
  24. would be reflected as 100% CPU activity, when in fact no work is
  25. being done.  It is not possible to objectively identify such
  26. "idle looping", so these CPU activity schemes are not effective.
  27.  
  28. Another way to determine whether the PC is being used would be to
  29. monitor an interrupt or interrupts that are used only when the PC
  30. is being used.  The keyboard interrupt was an obvious choice,
  31. since a person must be actually hitting the keys to drive that
  32. interrupt.  A mere count of keystrokes, however, is not a good
  33. measure of the level of usage of the PC, because of differences
  34. in typing speed and application design.  Simply browsing a file,
  35. for example, is a fine use of the PC that generates very few
  36. keystrokes.  To correct this shortcoming, KCOUNT measures the
  37. percentage of *minutes* in which there was one or more
  38. keystrokes.  Using this scheme, the power-typist and the browser
  39. should come out even in measured usage.
  40.  
  41. Care should be taken when using the results of KCOUNT's
  42. measurement.  KCOUNT does not measure a person's performance nor
  43. the overall usefullness of the computer.  It only measures
  44. "active" use of the computer.  Passive uses, such as long-running
  45. compiles, printing, or communications are not measured by KCOUNT.
  46.  
  47.  
  48. KCOUNT Compatibility
  49.  
  50. KCOUNT is compatible with most drivers and TSRs.  If you use
  51. SideKick, you should initialize KCOUNT first, then SideKick.
  52. Although KCOUNT offers the /E switch to de-install itself,
  53. this is not possible unless KCOUNT was the last TSR loaded.
  54. Thus the /E switch can not be used if you are running SideKick
  55. due to the way SideKick re-installs itself.
  56. KCOUNT V1.10 (C)Copyright Graeme W. McRae, November 1, 1986    Page 2
  57.  
  58.  
  59. KCOUNT Usage
  60.  
  61. To begin measurement, KCOUNT must be initialized using the /I
  62. option.  Thereafter, activity reports may be generated by using
  63. the KCOUNT command with no options.  The reports may be written
  64. to a file using the redirection character (">") on the command
  65. line. See "Collecting Statistics", below for more information
  66. about using files.
  67.  
  68. The /I option may be used to override the interrupt number used
  69. by KCOUNT.  If the interrupt number is overridden at
  70. initialization, it must also be overridden each time a report is
  71. desired.
  72.  
  73. The /R option will display the current report, then reset the
  74. statistics, in effect re-initializing KCOUNT.
  75.  
  76. The /P option may be used to override the default length of each
  77. measurement period.  The default is 60 seconds.  Any value from
  78. 10 to 3600 seconds may be used.
  79.  
  80. The /B option may be used for Brief output.  /Bxxxxxxxx attaches
  81. a name (I call it the B-Name) to the output.  See "Collecting
  82. Statistics", below, for more information on using the B-Name.
  83.  
  84. Any of the above options may be combined in one command.  The
  85. order of the options is not significant.  See the examples, below.
  86.  
  87. The /E option prints the final report, then shuts down KCOUNT,
  88. returning the storage formerly occupied by KCOUNT to DOS.
  89. It may be combined with /B.
  90.  
  91. The /H option will give a brief summary of command line syntax.
  92.  
  93.  
  94. KCOUNT Usage Examples
  95.  
  96.      KCOUNT /I     -- Initialize KCOUNT
  97.  
  98.      KCOUNT /I104  -- Initialize KCOUNT using interrupt 104 (decimal)
  99.  
  100.      KCOUNT /R     -- Reset statistics back to zero
  101.  
  102.      KCOUNT /I104/R -- Reset statistics, using interrupt 104 (decimal)
  103.  
  104.      KCOUNT /R/BAutoSig -- Reset statistics, assign name to reports
  105.  
  106.      KCOUNT /P300  -- Initialize or reset the period length (seconds)
  107.  
  108.      KCOUNT        -- Print the current activity report
  109.  
  110.      KCOUNT /B>>KSTATS.DAT -- Append the report to a file, brief mode
  111.  
  112.      KCOUNT /I104/B/E -- Print brief report using interrupt 103, then
  113.                       end collection for that interrupt.
  114.  
  115.      KCOUNT /H     -- Get help
  116. KCOUNT V1.10 (C)Copyright Graeme W. McRae, November 1, 1986    Page 3
  117.  
  118.  
  119. KCOUNT Collecting Statistics
  120.  
  121. Monitor reports can be directed to a file using the UNIX/DOS
  122. redirection symbols ">" (write) and ">>" (append).  Later, these
  123. reports can be printed or processed by a program of your
  124. devising.  The "Brief" mode facilitates this processing by writing
  125. exactly one line in a set format each time statistics are
  126. requested.  The "Title" parameter can be used to provide a title
  127. line as the first line of the file, if you wish.
  128.  
  129. If you are merging output collected from different computers or
  130. while running different applications, this name can be used to
  131. give more meaning to the data.  Normally, the B-Name supplied by
  132. /Bxxxxxxxx is used for the current report only.  But if /Bxxxxxxxx
  133. is combined with /I or /R, the B-Name becomes permanent, and will
  134. be used for all subsequent reports.  REMEMBER: If you use /R
  135. and /Bxxxxxxxx, the report will be issued using the *old* B-name,
  136. then the B-name (and other statistics) will be reset.
  137.  
  138. If you wish to compare the active use of two different programs,
  139. prog1 and prog2, you may wish to attach a B-Name to the
  140. statistics that are gathered while these programs are running.
  141. Later, SORT can be used to organize the statistics by program
  142. name.  Here is one scenario that will gather statistics using
  143. Brief mode:
  144.  
  145.      In AUTOEXEC.BAT
  146.      ------------
  147.           KCOUNT /I/T>>b:\kstats.dat    Write just the title line
  148.  
  149.      In the BAT file for PROG1
  150.      -------------------------
  151.           KCOUNT /R/Bprog1>b:\kstats.dat  Flush residual statistics
  152.           prog1
  153.           KCOUNT /R/B>>b:\kstats.dat   Write PROG1's statistics
  154.  
  155.           (The BAT file for PROG2 would be similar.)
  156.  
  157.      Generalized KCOUNT reset CED SYN
  158.      --------------------------------
  159.           syn k kcount/R/B%1>>b:\kstats.dat
  160.  
  161.           syn ed ^k Edlin^a:edlin %1^k
  162.  
  163.           Here, the "ed" syn invokes EDLIN, and keeps track of
  164.           keystrokes during the EDLIN session.
  165. KCOUNT V1.10 (C)Copyright Graeme W. McRae, November 1, 1986    Page 4
  166.  
  167.  
  168. KCOUNT Adjustable Interrupt Number
  169.  
  170. The interrupt (102 decimal, by default) is used both as a pointer
  171. to the data area used by the resident portion and as the
  172. programming interface to KCOUNT (See "Programming Interface"
  173. below).  If another program is using this interrupt, KCOUNT will not
  174. attempt to initialize itself.  In this case, you can tell KCOUNT
  175. to use a different interrupt number with the /Innn option, where
  176. nnn is the (decimal) interrupt number.  See "Changing the Default
  177. Interrupt Number", below for more information.
  178.  
  179. Multiple copies of KCOUNT can be run simultaneously using
  180. different interrupt numbers.  That way, monitoring can be done
  181. using two different recording periods at once.  Here's an
  182. example:
  183.  
  184.      KCOUNT /I103     -- Initialize KCOUNT using the default period.
  185.  
  186.      KCOUNT /I104/P300  -- Initialize a new copy of KCOUNT with a
  187.                            period of five minutes (300 seconds).
  188.  
  189.      KCOUNT /I103     -- Display the report of 60-second periods.
  190.  
  191.      KCOUNT /I104     -- Display the report of five-minute periods.
  192.  
  193. If you later use the /E switch to end KCOUNT, be sure to end in
  194. the reverse order that you initialized them.  Also, be sure to
  195. read "KCOUNT Compatibility", above.  To continue this example,
  196. you should issue end in this order:
  197.  
  198.      KCOUNT /I104/E
  199.  
  200.      KCOUNT /I103/E
  201.  
  202.  
  203. KCOUNT Report, normal mode
  204.  
  205. Application or computer name: bname.
  206. KCOUNT (V1.10)     status at: YY/MM/DD HH:MM:SS.
  207. KCOUNT has been running since YY/MM/DD HH:MM:SS.
  208. Keystrokes so far:            nnnnn.
  209. Number of seconds per period: nnnnn.
  210. Periods in which PC was used: nnnnn.
  211. Total number of time periods: nnnnn.
  212. Usage quotient:               nnn%
  213.  
  214.      If a B-Name was set at initialization or reset, this
  215.      name is printed, for your information.
  216.  
  217.      The current date and time and the date and time of
  218.      initialization are printed first, followed by the number of
  219.      keystrokes since initialization.  A "keystroke" is
  220.      considered to be a press of any key (including shift keys
  221.      and "dead" keys) or a typamatic repeat of any key.  If the
  222.      period was changed from the default of 60 seconds, the
  223.      number of seconds per period is printed.  Then, the number
  224.      of periods in which there was one or more keystrokes is
  225. KCOUNT V1.10 (C)Copyright Graeme W. McRae, November 1, 1986    Page 5
  226.  
  227.  
  228.      printed, followed by the total number of periods.  The ratio
  229.      of these last two numbers is the "Usage Quotient".
  230.  
  231.      The following rules pertain to the period of time that
  232.      elapses between keystrokes.  If the user sets the clock
  233.      back, or if the "BIOS tick count" is adjusted backwards (See
  234.      the explanation under "Warning: BIOS tick count was
  235.      adjusted", below) then the period of negative length is
  236.      ignored, and doesn't figure into the "Usage Quotient".  Any
  237.      period that spans midnight is ignored, because it is not
  238.      possible to distinguish this case from setting the clock
  239.      back.  (The date is not available to the resident portion.
  240.      It is printed for information purposes only)
  241.  
  242.  
  243. KCOUNT Report, Brief mode
  244.  
  245. B-Name Last keystroke Initialization Keystrokes Per. Used Total Percent
  246. bname  date/time      date/time        nnnnnnnn nnn nnnnn nnnnn nnn
  247.  
  248. Shown here is the title line, followed by the general form of the
  249. Brief-mode report.  It is scrunched a bit here, to fit into the
  250. format of this text file, but in reality, the lines are almost 80
  251. characters long.  The same statistics are printed, in the same
  252. order, as the normal-mode report.  But they are printed on one
  253. line.  This mode is designed primarily to simplify collection and
  254. processing of statistics.
  255.  
  256.  
  257.  
  258.  
  259. KCOUNT Messages
  260.  
  261. Error: interrupt nnn is already in use.  Use /Innn option.
  262.  
  263.      The interrupt is used by some software other than KCOUNT,
  264.      possibly a different version of KCOUNT or another TSR.  Use
  265.      the /Innn option, specifying an available interrupt.
  266.  
  267. KCOUNT is now installed.
  268.  
  269.      This message should be received after initialization of
  270.      KCOUNT, and at no other time.
  271.  
  272. Warning: BIOS tick count was adjusted from HH:MM:SS.hh to HH:MM:SS.hh
  273.  
  274.      This is an informational message, which can be safely
  275.      ignored.  Some PCs have clocks that are independent of the
  276.      BIOS tick count, which is stored at location 46C through
  277.      46F.  Typically, the DOS that runs on these PCs ignore the
  278.      BIOS tick count, leaving an incorrect value there.  KCOUNT
  279.      must rely on this value, however, because it isn't permitted
  280.      to use the DOS "time" service.  So during initialization,
  281.      KCOUNT corrects this tick count if necessary, and issues
  282.      this message.  This correction is also done whenever a
  283.      monitor report is requested.
  284. KCOUNT V1.10 (C)Copyright Graeme W. McRae, November 1, 1986    Page 6
  285.  
  286.  
  287. /Pnnnn value must be 10 to 3600.
  288.  
  289.      The number of seconds per period must be in this range.
  290.  
  291. /Innn value must be 1 to 255.
  292.  
  293.      The interrupt number must be in this range, although it is
  294.      highly recommended that you either take the default or
  295.      choose a number from 96 through 111.  All numbers are
  296.      decimal.
  297.  
  298. Counter overflow:  Reset using KCOUNT /R.
  299.  
  300.      The running count of recording periods can reach at most
  301.      65535.  This happens after 7 days using the shortest
  302.      recording period (10 seconds), or after 6 weeks using the
  303.      default recording period (60 seconds).  If this does happen,
  304.      issue the command KCOUNT /R to reset the counters.
  305.  
  306. Bad parm syntax.
  307. For help, use KCOUNT /H
  308.  
  309.      Probably you forgot the slash, or made some other typing
  310.      error.
  311.  
  312. KCOUNT 1.10 (C)Copyright Graeme W. McRae 1986
  313. For help, use KCOUNT /H
  314.  
  315.      If KCOUNT was never installed, and you enter the KCOUNT command
  316.      with no operands, this message appears.  Or it appears when
  317.      you try to use parameters that would be valid if KCOUNT were
  318.      initialized.
  319.  
  320. Checksum error.  Get a new copy of KCOUNT.
  321.  
  322.      There was a bad download or copy of KCOUNT.  Try downloading
  323.      it again, or obtain a new copy from the author.
  324.  
  325. KCOUNT ended.
  326.  
  327.      The /E parameter was specified, so the resident portion of
  328.      KCOUNT was freed, and the interrupt vector hooks were removed.
  329.  
  330. Error: memory not released.
  331.  
  332.      The /E parameter was specified, and the interrupt vector hooks
  333.      were probably removed, but the memory blocks owned by the
  334.      resident portion of KCOUNT were corrupted, and thus not freed.
  335.  
  336. Error: /E not possible.
  337.  
  338.      The /E parameter was specified, but the interrupt vector table
  339.      was modified after KCOUNT was installed, so the information
  340.      KCOUNT needs to end is not available.
  341. KCOUNT V1.10 (C)Copyright Graeme W. McRae, November 1, 1986    Page 7
  342.  
  343.  
  344. KCOUNT Programming Interface
  345.  
  346. Programs may access the KCOUNT numbers directly, by invoking the
  347. KCOUNT interrupt.  Seven functions are available.  The function
  348. number must be stored in the AH register prior to invoking the
  349. interrupt.  The values returned are accurate up to the most
  350. recent keystroke.
  351.  
  352.      Function 1: Return the total number of keystrokes in DX:AX
  353.  
  354.      Function 2: Return the total periods and used periods.  The
  355.      number of total periods is returned in DX, and the number of
  356.      used periods is returned in AX.
  357.  
  358.      Function 3: Return the time KCOUNT was initialized.  The
  359.      time is returned in DH:DL:AH:AL as hours, minutes, seconds,
  360.      and hundredths of seconds.
  361.  
  362.      Function 4: Return the number of seconds per period in AX.
  363.  
  364.      Function 5: Re-initialize KCOUNT.  The time of
  365.      initialization is reset to the time the last keystroke
  366.      occurred.
  367.  
  368.      Function 6: Returns a segmented pointer in DS:SI to the name
  369.      specified by the last permanent /Bxxxxxxxx parameter.  The
  370.      format is a one-byte length followed by an 8-character
  371.      blank-padded ASCIIZ string.  The choice of DS:SI made KCOUNT
  372.      programming easier, sorry.
  373.  
  374.      Function 7: Returns the date KCOUNT was initialized, in
  375.      the same format as DOS function 2Ah.  CX=Year, DH=Month,
  376.      DL=Day of month, and AL=Day of week.
  377.  
  378.  
  379. KCOUNT Changing the Default Interrupt Number
  380.  
  381. The default interrupt number used by KCOUNT is 66h (102 decimal).
  382. If this interrupt number interferes with one of your existing
  383. TSRs, you can change it permanently.  When you do this, the /Help
  384. message will automatically change as well.  It is recommended that
  385. you choose an available interrupt in the range 60h through 6Fh.
  386. Here's how you would change it to 6Eh:
  387.  
  388.      A>debug kcount.com
  389.      -e 103 6E
  390.      -g
  391.      Checksum error.  Get a new copy of KCOUNT.
  392.      Program terminated normally.
  393.      -w
  394.      Writing 0FEE bytes
  395.      -q
  396.      A>
  397. KCOUNT V1.10 (C)Copyright Graeme W. McRae, November 1, 1986    Page 8
  398.  
  399.  
  400. Similarly, to change the default measurement interval from 60
  401. seconds to some other number, the "e" command becomes "e 104 xx
  402. yy" where xx is the least significant byte and yy is the most
  403. significant byte of the default measurement interval in hex.
  404.  
  405. Note that you must G>o (run the program) under debug after making
  406. a change before writing the changed version back to disk.
  407. Running the program automatically re-calculates the checksum.
  408. So even though the error message was issued, W>riting fixes it.
  409.  
  410.  
  411. KCOUNT History of Revisions
  412.  
  413. 86/10/08 V1.00 Initial release supported /I, /Innn, /P, /R, and /H.
  414.  
  415. 86/10/20 V1.01 Added self-checksum support to guard against a
  416. possible bad download or bad copy of the program.  Total size
  417. of KCOUNT.COM is under 3K.
  418.  
  419. 86/10/31 V1.10 Added /B, /T, and /E.  The date was added to the
  420. display, but it is not used in calculations.  The /R and /P
  421. switches were changed to show the report *before* rather than
  422. *after* the reset of statistics.  Total size of KCOUNT.COM is
  423. under 4K.
  424.  
  425. IBM is a registered trademark of International Business Machines
  426. Corporation.
  427.  
  428. Sidekick is a trademark of Borland International, Inc.
  429.  
  430. MS-DOS is a trademark of Microsoft Corporation.
  431.  
  432. UNIX is a trademark of AT&T Bell Laboratories.
  433.  
  434. CED is Copyright 1985 by Christopher J. Dunford
  435.  
  436. If you have any questions about this program, feel free to send
  437. me EMAIL on CompuServe.  You may distribute KCOUNT, but you must
  438. include this documentation, you may not sell it (you may charge
  439. for materials, handling, and postage), and you may not distribute
  440. a modified version of KCOUNT nor its documentation.
  441. Graeme W. McRae [73307,2453].
  442.