File: bench.lisp

package info (click to toggle)
acl2 8.6%2Bdfsg-2
  • links: PTS
  • area: main
  • in suites: trixie
  • size: 1,111,420 kB
  • sloc: lisp: 17,818,294; java: 125,359; python: 28,122; javascript: 23,458; cpp: 18,851; ansic: 11,569; perl: 7,678; xml: 5,591; sh: 3,976; makefile: 3,833; ruby: 2,633; yacc: 1,126; ml: 763; awk: 295; csh: 233; lex: 197; php: 178; tcl: 49; asm: 23; haskell: 17
file content (122 lines) | stat: -rw-r--r-- 4,762 bytes parent folder | download | duplicates (3)
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
(in-package 3bz)

#++(ql:quickload '(3bz salza2 flexi-streams chipz deoxybyte-gzip))


(defvar *foo* nil)
(defvar *chipz* nil)
(defvar *3bz* nil)
#++
(prog1 nil
  (push *foo* *chipz*))
#++
(prog1 nil
  (push *foo* *3bz*))

(defvar *zzz* nil)
(let* ((d (time
           (alexandria:read-file-into-byte-vector "e:/tmp/t/linux-2.2.26.tar"))
          #++(setf *foo*
                   (time
                    (map-into (make-array (expt 2 24) :element-type 'octet)
                              (lambda () (random 225))))))
       (tmp (make-array (length d) :element-type 'octet
                                   :initial-element 0))
       (v #++(time
              (salza2:compress-data d 'salza2:deflate-compressor))
          (or *zzz*
              (setf *zzz*
                    (time
                     (multiple-value-bind (x r w)
                         (gz:deflate-vector d tmp :compression 9
                           :suppress-header t)
                       (declare (ignore r))
                       (subseq x 0 w))))))
       (c (make-instance 'octet-vector-context
                         :octet-vector v
                         :boxes (make-context-boxes :end (length v))))
       (state (make-deflate-state :output-buffer tmp)))
  #++(time (dump-deflate v "-sirqq"))
  #++(time (dump-deflate v "-sir"))
  (format t "chipz:~%")
  (fill tmp 0)
  (with-simple-restart (continue "continue")
    (let ((x (time (chipz:decompress tmp 'chipz:deflate v))))
      (declare (ignore x))
      (assert (equalp d tmp))))
  (fill tmp 0)
  (format t "3bz:~%") ;; 0.36
  (let ((x (time (decompress c state))))
    (assert (not (ds-output-overflow state)))
    (assert (ds-finished state))
    (assert (equalp (typecase x
                      (cons
                       (time (apply 'concatenate 'octet-vector x)))
                      (vector x)
                      (number
                       (subseq tmp 0 x)))
                    d)))
  (fill tmp 0)
  (format t "3bz/pointer:~%") ;; 0.36
  (cffi:with-pointer-to-vector-data (p v)
    (with-octet-pointer (op p (length v))
      (let ((x (time (decompress (make-instance 'octet-pointer-context
                                                :pointer p :op op
                                                :boxes (make-context-boxes :end (length v)))
                                 (make-deflate-state :output-buffer tmp)))))
        (assert (equalp (if (consp x)
                            (time (apply 'concatenate 'octet-vector x))
                            (subseq tmp 0 x))
                        d)))))
  (fill tmp 0)
  (format t "3bz/stream:~%")
  (flex:with-input-from-sequence (s v)
    (let ((x (time (decompress (make-instance 'octet-stream-context
                                              :octet-stream s
                                              :boxes (make-context-boxes :end (length v)))
                               (make-deflate-state :output-buffer tmp)))))
      (assert (equalp (if (consp x)
                          (time (apply 'concatenate 'octet-vector x))
                          (subseq tmp 0 x))
                      d))))

  (fill tmp 0)
  (format t "gz:~%")
  (let ((x (time (gz:inflate-vector v tmp :suppress-header t))))
    (assert (equalp x d)))
  (print (length v))
  nil)

(let* ((d (time
           (alexandria:read-file-into-byte-vector "e:/tmp/t/linux-2.2.26.tar")))
       (tmp (make-array (length d) :element-type 'octet
                                   :initial-element 0))
       (v (or *zzz*
              (setf *zzz*
                    (time
                     (multiple-value-bind (x r w)
                         (gz:deflate-vector d tmp :compression 9
                           :suppress-header t)
                       (declare (ignore r))
                       (subseq x 0 w)))))))
  (fill tmp 0)
  (format t "3bz:~%") ;; 0.33
  (let ((x (time (decompress (make-instance 'octet-vector-context
                                            :octet-vector v
                                            :boxes (make-context-boxes
                                                    :end (length v)))
                             (make-deflate-state :output-buffer tmp)))))
    (assert (equalp (if (consp x)
                        (time (apply 'concatenate 'octet-vector x))
                        (subseq tmp 0 x))
                    d)))
  (format t " x10:~%")
  (time
   (loop repeat 10
         do (decompress (make-instance 'octet-vector-context
                                       :octet-vector v
                                       :boxes (make-context-boxes
                                               :end (length v)))
                        (make-deflate-state :output-buffer tmp))))

  nil)