7a这道题目有点难,牵涉到时间测试,这里先提供一个简易时间测试函数(或许您有更好的,权当献丑吧^_^)- ;;;小函数测试时间,ti为使用次数,funname为函数名,funarglist为函数funname的参数列表
- ;;;如(powerset (list 1 2 3))测试100000次运行时间使用代码为
- ;;; (times 100000 'powerset (list (list 1 2 3)))
- (defun times (ti funname funarglist / t1 t2)
- (setq t1 (getvar "date"))
- (repeat ti
- (vl-catch-all-apply
- funname
- funarglist
- )
- )
- (setq t2 (getvar "date"))
- (princ "函数:")
- (princ funname)
- (princ (strcat "运行" (rtos ti 2 0) "次" ))
- (princ "测试结果")
- (princ (menucmd (strcat "M=$(edtime,"
- (rtos (- t2 t1) 2 16)
- ",HH:MM:SS:MSEC)"
- )
- )
- )
- )
|