对熊掌的说法略有不同。- ;计时器开始******************
- (defun cx-jsq () ;计时器开始
- (setq time_tmp (getvar "TDUSRTIMER"))
- )
- ;计时器结束*****************
- (defun cx-end-jsq () ;计时器结束
- (setq time_tmp (- (getvar "TDUSRTIMER") time_tmp)
- ;获得时间,单位小时
- time_tmp (* time_tmp 86400)
- ) ;秒为单位
- (prompt (strcat "用时" (rtos time_tmp 2 4) "秒"))
- (setq time_tmp nil)
- (princ)
- )
- ;;;准备测试的数据表
- (defun c:xx()
- (setq all_lst nil)
- (setq lst '((0 0 0)(1 1 0)))
- (repeat 10000
- (setq all_lst(cons lst all_lst))
- )
- (princ)
- )
- ;;;repeat
- (defun c:xx1()
- (setq all_lst1 all_lst)
- (setq n (length all_lst1))
- (cx-jsq)
- (repeat n
- (setq x (car all_lst1))
- (entmake (list '(0 . "line") (cons 10 (car x)) (cons 11 (cadr x))))
- (setq ll_lst1 (cdr ll_lst1))
- )
- (cx-end-jsq)
- (princ)
- )
- ;;;foreach
- (defun c:xx2()
- (setq all_lst1 all_lst)
- (cx-jsq)
- (foreach x all_lst1
- (entmake (list '(0 . "line") (cons 10 (car x)) (cons 11 (cadr x))))
- )
- (cx-end-jsq)
- (princ)
- )
- ;;;mapcar
- (defun c:xx3()
- (setq all_lst1 all_lst)
- (cx-jsq)
- (mapcar '(lambda (x)
- (entmake (list '(0 . "line") (cons 10 (car x)) (cons 11 (cadr x)))))
- all_lst1
- )
- (cx-end-jsq)
- (princ)
- )
测试结果很明显和熊掌的不一样~~~~
命令: xx
命令:
命令: xx1
用时0.202秒
命令:
命令: xx2
用时0.221秒
命令:
命令: xx3
用时0.24秒
命令:
|