File tree 3 files changed +46
-6
lines changed
3 files changed +46
-6
lines changed Original file line number Diff line number Diff line change
1
+ (in-package # :rope/dev)
2
+
3
+ ; ; (progn
4
+ ; ; (sb-ext:restrict-compiler-policy 'speed 3 3)
5
+ ; ; (sb-ext:restrict-compiler-policy 'debug 0 0)
6
+ ; ; ;; (sb-ext:restrict-compiler-policy 'space 0 0)
7
+ ; ; (sb-ext:restrict-compiler-policy 'safety 0 0))
8
+
9
+
10
+ (defparameter *readme*
11
+ (merge-pathnames " README.md" (asdf :system-source-directory :rope )))
12
+
13
+ (defun print-time (time reps length )
14
+ (format t " rope size: ~a , ~a microseconds~% "
15
+ length
16
+ (* 1000000 (/ time reps))))
17
+
18
+ (defmacro time* (&body body)
19
+ ` (let ((time ))
20
+ (sb-ext :call-with-timing
21
+ (lambda (&rest plist) (setf time (getf plist :real-time-ms )))
22
+ (lambda () ,@ body))
23
+ (coerce (/ time 1000 ) ' float)))
24
+
25
+ (defun benchmark-insert (&optional (reps 1000000 ))
26
+ (with-open-file (s *readme* )
27
+ (let* ((starting-rope (split-rope (make-rope s) 1000 ))
28
+ (rope starting-rope))
29
+ (dotimes (i 100 )
30
+ (print-time
31
+ (time*
32
+ (dotimes (i reps)
33
+ (insert-rope rope (random (rope-length rope)) " Hello, world!" )))
34
+ reps
35
+ (rope-length rope))
36
+ (force-output )
37
+ (setf rope (concat-rope rope starting-rope))))))
Original file line number Diff line number Diff line change 22
22
(let ((obj (root-rope obj)))
23
23
(graph-object-points-to self obj)))
24
24
25
- (defmethod graph-object-node ((self (eql ' rope)) (obj branch))
25
+ (defmethod graph-object-node ((self (eql ' rope)) (obj rope :: branch))
26
26
(make-instance ' node
27
27
:attributes ` (:label , (format nil " length: ~a~% depth: ~a "
28
28
(rope-length obj)
29
29
(rope-depth obj)))))
30
30
31
- (defmethod graph-object-points-to ((self (eql ' rope)) (obj branch))
31
+ (defmethod graph-object-points-to ((self (eql ' rope)) (obj rope :: branch))
32
32
(list (make-instance ' attributed
33
- :object (branch-right obj)
33
+ :object (rope :: branch-right obj)
34
34
:attributes ` (:label " R" ))
35
35
(make-instance ' attributed
36
- :object (branch-left obj)
36
+ :object (rope :: branch-left obj)
37
37
:attributes ` (:label " L" ))))
38
38
39
- (defmethod graph-object-node ((self (eql ' rope)) (obj leaf))
39
+ (defmethod graph-object-node ((self (eql ' rope)) (obj rope :: leaf))
40
40
(make-instance ' node
41
41
:attributes ` (:label , (format nil " ~a "
42
42
(rope ::leaf-string obj))
Original file line number Diff line number Diff line change 1
1
(defpackage #:rope/dev
2
2
(:use # :cl # :cl-dot # :rope)
3
3
(:export
4
- # :graph-ropes))
4
+ ; ; graphviz.lisp
5
+ # :graph-ropes
6
+ ; ; benchmark.lisp
7
+ ))
You can’t perform that action at this time.
0 commit comments