git.fiddlerwoaroof.com
Raw Blame History
(defpackage #:test-clim
  (:use #:clim #:clim-lisp))
(in-package #:test-clim)
(shadow 'inspect)

(defun tokenize (string)
  (loop with result = '()
        with word = '()
        for char across string
        when (or (char= char #\space) (char= char #\newline) (char= char #\tab))
          do (progn (push (reverse (coerce word 'string)) result)
                    (setf word '()))

        unless (or (char= char #\space) (char= char #\newline) (char= char #\tab))
          do (push char word)

        finally (progn (push (reverse (coerce word 'string)) result)
                       (return (reverse result)))))

(defparameter *records*
  '(
"Networks are in trouble. The volume of data, applications and transactions hitting data centers is increasing at an exponential pace. Add in predictions that by 2020 users will own as many as 25 connected devices and, according to Cisco, the Internet of Things will account for as many as 50 billion new IP-enabled devices and you can see a tsunami of traffic headed our way."

"Networking systems built around multi-purpose processors are about to slam into a price/performance wall that will either choke traffic or break networking budgets."

"Recently, Google engineers blogged about a new ASIC they developed, called a Tensor Processing Unit designed to accelerate machine-learning applications.  They argue that this ASIC has fast-forwarded their technology by seven years, allowing them to leapfrog competition and “squeeze more operations per second into the silicon, use more sophisticated and powerful machine learning models, and apply these models more quickly, so users get more intelligent results more rapidly.”"

"There are a number of challenges for other companies interested in this approach. The development of ASICs is resource-intensive and time consuming."

"Setting aside issues like the shortage of available talent and the average of four years to develop and bring a new ASIC to market, the material costs alone are high. The manufacturing of a typical two-gram chip requires 1.6 kilograms of fossil fuel, 72 grams of chemicals, and 32 kilograms of water. The materials involved in making a 32Mbit RAM chip can add up to as much as 630 times the mass of the final product."

"Market analysts and business leaders for years have discounted the value of ASICs. They argued that the time to develop the hardware, design the firmware, and incorporate the technology into current programming and development processes is too expensive. They complain that it can slow down their ability to respond to market changes and say multi-purpose CPUs are fast, cheap and easy to write software for."

"However, general-purpose microprocessors are about to run up against the limits of Moore's law. Features in some of Intel’s latest chips are said to be just 100 atoms wide. To keep up with current demand, that same chip by 2020 will need to have features ten atoms wide."

"IBM announced they are spending $3 billion to develop a new generation of microprocessors. It estimates its state-of-the-art chips will use a 7nm process in five years. At that size reliability becomes a serious issue with manufacturing errors and even quantum challenges."
    ))

(declaim (optimize (debug 3)))

(define-application-frame
  test-clim ()

  ()
  (:pointer-documentation t)
  (:panes
    (app :application
         :height 400 :width 600
         :display-time nil
         :scroll-bars :vertical)
    (int :interactor :height 100 :width 600))
  (:layouts
    (default (horizontally () app int))))

(defun app-main ()
  (let ((frame (make-application-frame 'test-clim)))
    (run-frame-top-level frame)))

(define-test-clim-command (com-quit :name t) ()
  (frame-exit *application-frame*))

(test-clim::define-test-clim-command (inspect :name t) ()
 (clouseau:inspector
   (clim:stream-output-history
     (clim:find-pane-named clim:*application-frame* 'test-clim::app))))

(define-test-clim-command (com-put-records :name t) ()
  (let* ((pane (clim:find-pane-named clim:*application-frame* 'app))
         (history (clim:stream-output-history pane))
         (record-strings
           (mapcar (lambda (text)
                     (with-output-to-string (pane)
                       (pprint-logical-block (pane (tokenize text))
                         (pprint-indent :block 4 pane)
                         (loop
                           (pprint-exit-if-list-exhausted)
                           (princ (pprint-pop) pane)
                           (pprint-exit-if-list-exhausted)
                           (princ #\space pane)
                           (pprint-newline :fill pane)))))
                   *records*))
         (records (mapcar (lambda (text)
                            (clim:with-output-to-output-record (pane)
                              (princ text pane)))
                          (apply #'concatenate 'list
                                 (mapcar (lambda (x) (serapeum:split-sequence #\newline x))
                                         record-strings)))))
    (loop for n from 0
          for record in records
          do (climacs-flexichain-output-history:insert history record n))
    (climacs-flexichain-output-history:change-space-requirements history)
    (clim:replay history pane)))

(define-test-clim-command (com-put-records1 :name t) ()
  (let* ((pane (clim:find-pane-named clim:*application-frame* 'app))
         (history (clim:stream-output-history pane))
         (records (mapcar (lambda (text)
                            (clim:with-output-to-output-record (pane)
                              (pprint-logical-block (pane (tokenize text))
                                (pprint-indent :block 4 pane)
                                (loop
                                  (pprint-exit-if-list-exhausted)
                                  (princ (pprint-pop) pane)
                                  (pprint-exit-if-list-exhausted)
                                  (princ #\space pane)
                                  (pprint-newline :fill pane)))))
                          *records*)))
    (mapcar (lambda (record)
              (climacs-flexichain-output-history:insert history record 0)
              (climacs-flexichain-output-history:change-space-requirements history) 
              (clim:replay history pane))
            records)))

(define-test-clim-command (com-initialize :name t) () ()
  (let ((pane (clim:find-pane-named clim:*application-frame* 'app)))
    (setf (clim:stream-recording-p pane) nil)
    ;(setf (clim:stream-end-of-line-action pane) :allow)
    (change-class (clim:stream-output-history pane)
                  'climacs-flexichain-output-history:flexichain-output-history
                  :parent pane)))


#+os-macosx (setf mcclim-truetype:*truetype-font-path* "/Library/Fonts/")
(app-main)