(FILECREATED "10-Sep-85 15:34:48" {IVY}<JELLINEK>LISP>OPCODEHIST.;2 4799   

      changes to:  (FNS \HIST.REPAINTFN MAKE.HISTOGRAM.WINDOW \HIST.RESHAPEFN SORT&COPY.OPCODE.ARRAY 
			HIST.DRAWBOX)
		   (VARS OPCODEHISTCOMS HIST.WINDOW)

      previous date: " 6-Sep-85 13:06:45" {ERIS}<LISPCORE>PROLOG>OPCODEHIST.;1)


(* Copyright (c) 1985 by Xerox Corporation. All rights reserved.)

(PRETTYCOMPRINT OPCODEHISTCOMS)

(RPAQQ OPCODEHISTCOMS ((FNS HIST.DRAWBOX MAKE.HISTOGRAM.WINDOW SORT&COPY.OPCODE.ARRAY \HIST.REPAINTFN 
			    \HIST.RESHAPEFN)))
(DEFINEQ

(HIST.DRAWBOX
  [LAMBDA (MAXWIDTH HEIGHT VALUE MAXVALUE YPOS SHADE LABEL STREAM)
                                                             (* hdj " 6-Sep-85 16:40")
    (LET ((SCALE (FQUOTIENT MAXWIDTH MAXVALUE)))
         (BLTSHADE SHADE STREAM 0 YPOS (FIX (TIMES SCALE VALUE))
		   HEIGHT)
         (MOVETO 0 YPOS STREAM)
         (DRAWTO 0 (IPLUS YPOS HEIGHT)
		 1 NIL STREAM)
         (DRAWTO (FIX (TIMES SCALE VALUE))
		 (IPLUS YPOS HEIGHT)
		 1 NIL STREAM)
         (DRAWTO (FIX (TIMES SCALE VALUE))
		 YPOS 1 NIL STREAM)
         (DRAWTO 0 YPOS 1 NIL STREAM)
         (MOVETO 0 (IPLUS YPOS 2)
		 STREAM)
         (PRINTOUT STREAM LABEL])

(MAKE.HISTOGRAM.WINDOW
  [LAMBDA NIL
    (DECLARE (GLOBALVARS PROLOG.ENABLE.PUFN.TABLE HIST.WINDOW))
                                                             (* hdj "10-Sep-85 15:32")
    (LET ((BARHEIGHT 12)
	  (WINDOW (CREATEW NIL "Opcode frequencies"))
	  (HIST.ARRAY (SORT&COPY.OPCODE.ARRAY PROLOG.ENABLE.PUFN.TABLE)))
         (WINDOWPROP WINDOW (QUOTE HIST.ARRAY)
		     HIST.ARRAY)
         (WINDOWPROP WINDOW (QUOTE MAXFREQ)
		     (for INSTRUCTION from 0 to 255 largest (ELT PROLOG.ENABLE.PUFN.TABLE INSTRUCTION)
			finally (RETURN $$EXTREME)))
         (WINDOWPROP WINDOW (QUOTE TOTALRUN)
		     (for INSTRUCTION from 0 to 255 sum (ELT PROLOG.ENABLE.PUFN.TABLE INSTRUCTION)))
         (WINDOWPROP WINDOW (QUOTE REPAINTFN)
		     (FUNCTION \HIST.REPAINTFN))
         (WINDOWPROP WINDOW (QUOTE RESHAPEFN)
		     (FUNCTION \HIST.RESHAPEFN))
         (WINDOWPROP WINDOW (QUOTE SCROLLFN)
		     (FUNCTION SCROLLBYREPAINTFN))
         (WINDOWPROP WINDOW (QUOTE BARHEIGHT)
		     BARHEIGHT)
         (\HIST.RESHAPEFN WINDOW)
     WINDOW])

(SORT&COPY.OPCODE.ARRAY
  [LAMBDA (ARRAY)                                            (* hdj "10-Sep-85 15:09")
    (LET ([OP/FRQ.PAIRS (SORT (for OP# from 0 to 255 collect (CONS OP# (ELT ARRAY OP#)))
			      (FUNCTION (LAMBDA (A B)
				  (ILEQ (CDR A)
					(CDR B]
	  (RESULT (ARRAY 256 (QUOTE POINTER)
			 NIL 0)))
         (for PAIR in OP/FRQ.PAIRS as ARRAYELT from 0 do (SETA RESULT ARRAYELT PAIR))
     RESULT])

(\HIST.REPAINTFN
  [LAMBDA (WINDOW REGION)                                    (* hdj "10-Sep-85 15:32")
    (LET* [(BARHEIGHT (WINDOWPROP WINDOW (QUOTE BARHEIGHT)))
	   (TOPINSTRUCTION (IQUOTIENT (fetch (REGION TOP) of REGION)
				      BARHEIGHT))
	   (BOTTOMINSTRUCTION (IMAX (IQUOTIENT (fetch (REGION BOTTOM) of REGION)
					       BARHEIGHT)
				    0))
	   (EXTENTHEIGHT (TIMES 256 BARHEIGHT))
	   (HIST.ARRAY (WINDOWPROP WINDOW (QUOTE HIST.ARRAY)))
	   (WWIDTH (WINDOWPROP WINDOW (QUOTE WIDTH)))
	   (MAXVALUE (WINDOWPROP WINDOW (QUOTE MAXFREQ)))
	   (TOTAL.INSTRUCTIONS.RUN (WINDOWPROP WINDOW (QUOTE TOTALRUN]
          (DSPOPERATION (QUOTE PAINT)
			WINDOW)
          (DSPFONT (FONTCREATE (QUOTE GACHA)
			       10
			       (QUOTE BRR))
		   WINDOW)
          (for INSTRUCTION from TOPINSTRUCTION to BOTTOMINSTRUCTION by -1
	     do (LET* ((INSTR&FREQ (ELT HIST.ARRAY INSTRUCTION))
		       (INSTR (CAR INSTR&FREQ))
		       (FREQ (CDR INSTR&FREQ)))
		      (HIST.DRAWBOX WWIDTH BARHEIGHT FREQ MAXVALUE (ITIMES INSTRUCTION BARHEIGHT)
				    10260
				    (CONCAT INSTR "  (" FREQ " = " (FIX (TIMES 100 (FQUOTIENT FREQ 
									   TOTAL.INSTRUCTIONS.RUN)))
					    "%%)")
				    WINDOW])

(\HIST.RESHAPEFN
  [LAMBDA (WINDOW)                                           (* hdj "10-Sep-85 15:21")
    (LET [(EXTENT (CREATEREGION 0 0 (WINDOWPROP WINDOW (QUOTE WIDTH))
				(ITIMES 256 (WINDOWPROP WINDOW (QUOTE BARHEIGHT]
         (WINDOWPROP WINDOW (QUOTE EXTENT)
		     EXTENT)
         (REDISPLAYW WINDOW EXTENT])
)
(PUTPROPS OPCODEHIST COPYRIGHT ("Xerox Corporation" 1985))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (557 4718 (HIST.DRAWBOX 567 . 1290) (MAKE.HISTOGRAM.WINDOW 1292 . 2481) (
SORT&COPY.OPCODE.ARRAY 2483 . 2987) (\HIST.REPAINTFN 2989 . 4349) (\HIST.RESHAPEFN 4351 . 4716)))))
STOP