xshrimp 发表于 2008-3-4 13:21:00

测试程序运行效率程序

本帖最后由 作者 于 2008-3-4 19:01:15 编辑

;;;测试程序运行效率程序-----------------------------------------
(defun gps->test (lst / rlst rmax rxlst start-time tlst x y z)
(setq tlst lst)
(setq rlst (mapcar
      '(lambda (x)
(setq start-time (getvar "cdate"))
(eval x)
(* 1000000 (- (getvar "cdate") start-time))
       )
      tlst
    )
)

(setq rmax(apply 'max rlst))
(setq rxlst (mapcar
       '(lambda (x)
          (cond ((= 0 x) "∞")
         (T (/ rmax x))
         )
      )
       rlst
   )
)
(princ "\n测试程序......流逝时间(秒)......相对速度")
(mapcar
    '(lambda (x y z)
       (mapcar
'princ
(list "\n"x "......" y "......" z)
       )
   )
    tlst
    rlst
    rxlst
)
(princ)
)
;;;示例:---------------------------------------------------
(defun test1 (ss)
(vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
)
(defun test2 (ss / n l)
(repeat (setq n (sslength ss))
    (setq l (cons (ssname ss (setq n (1- n))) l))
)
)
(defun test3 (ss / n e l)
(setq n -1)
(while (setq e (ssname ss (setq n (1+ n))))
    (setq l (cons e l))
)
)
;|
命令: (setq ss (ssget))      
命令: (gps->test '((test1 ss) (test2 ss) (test3 ss)))
      测试程序......流逝时间(秒)......相对速度
      (TEST1 SS)......1.04308......1.0
      (TEST2 SS)......0.111759......9.33333
      (TEST3 SS)......0.0782311......13.3333
e.g.
(gps->test '((c:pw) (c:wq)))
|;

smartstar 发表于 2013-4-4 12:14:34

老大的源码,竟然没有顶过!!

wowan1314 发表于 2013-4-4 19:39:49

同顶,,,,,,
页: [1]
查看完整版本: 测试程序运行效率程序