File: test.l

package info (click to toggle)
euslisp 9.27%2Bdfsg-7
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 55,344 kB
  • sloc: ansic: 41,162; lisp: 3,339; makefile: 256; sh: 208; asm: 138; python: 53
file content (77 lines) | stat: -rw-r--r-- 2,391 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
;; bench mark test for type discrimination and memory allocation speed
;;
;;	T.Matsui

(defmethod cons (:test () ))

#+eus
(defun gbc (x) (gc))

(defun prtime (func tm1 tm2)
  (format t "func ~A~%" (* 0.0167 (- tm2 tm1))))

(defun bench (m n)
     (declare (integer m n))
   (let (tm1 tm2 overhead1 overhead2 dummy)
     (setq tm1 (runtime))
     (dotimes (i m) )
     (setq tm2 (runtime))
     (setq overhead1 (- tm2 tm1))
     (setq tm1 (runtime))
     (dotimes (i n) )
     (setq tm2 (runtime))
     (setq overhead2 (- tm2 tm1))
;;
     (setq tm1 (runtime))
     (dotimes (i m)  (setq dummy (symbolp 'a)))
     (setq tm2 (runtime))
     (format t "symbolp ~a microsec.~%"  (* 1e6 (/ (* 0.0167 (- tm2 tm1 overhead1)) m)))
     (setq tm1 (runtime))
     (dotimes (i m)  (setq dummy (consp 'a)))
     (setq tm2 (runtime))
     (format t "consp ~a microsec.~%" (* 1e6  (/ (* 0.0167 (- tm2 tm1 overhead1)) m)))
#+eus
     (progn
	     (setq tm1 (runtime))
	     (dotimes (i m)  (derivedp 'a symbol))
	     (setq tm2 (runtime))
	     (format t "derivedp ~a microsec ~%"  (* 1e6 (/ (* 0.0167 (- tm2 tm1 overhead1)) m))))
#+eus
     (progn
	     (setq tm1 (runtime))
	     (dotimes (i m)  (send '(a) :test))
	     (setq tm2 (runtime))
	     (format t "send ~a microsec~%" 
			(* 1e6 (/  (* 0.0167 (- tm2 tm1 overhead1)) m))))
     (gbc t)
     (setq tm1 (runtime))
     (dotimes (i n)  (setq dummy (cons nil nil)))
     (setq tm2 (runtime))
     (format t "cons ~a microsec~%" (* 1e6 (/ (* 0.0167 (- tm2 tm1 overhead2)) n)))
     (gbc t)
     (setq tm1 (runtime))
     (dotimes (i n)  (make-string 10))
     (setq tm2 (runtime))
     (format t "make-string ~a microsec~%"  (/ (* 1e6 0.0167 (- tm2 tm1 overhead2)) n))
     (gbc t)
     (setq tm1 (runtime))
     (dotimes (i n)  (vector 1 2 3))
     (setq tm2 (runtime))
     (format t "3dvector ~a microsec ~%"  (/ (* 1e6 0.0167 (- tm2 tm1 overhead2)) n))
     (gbc t)
     (setq tm1 (runtime))
     (dotimes (i n)  (vector 1 2 3 4 5 6 7 8 9 10))
     (setq tm2 (runtime))
     (format t "10dvector ~a microsec ~%"  (/ (* 1e6 0.0167 (- tm2 tm1 overhead2)) n))
     (gbc t)
     (setq tm1 (runtime))
     (dotimes (i n) 
	 (vector 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))
     (setq tm2 (runtime))
     (format t "30dvector ~a microsec~%" 
	 (/ (* 1e6 0.0167 (- tm2 tm1 overhead2)) n))))