Author Topic: ( Challenge ) Shortest & Longest line  (Read 12150 times)

0 Members and 1 Guest are viewing this topic.

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1451
  • Marco
Re: ( Challenge ) Shortest & Longest line
« Reply #45 on: January 31, 2013, 02:45:51 PM »
Try running that on this specs

Memory 1.00 GB
Intel Atom (TM) CPU N455 @1.66GHz

OS: Windows 7 Starter
CAD Version: Autocad 2009

I bet you wouldnt like what you see  ;D
Intel Core2Duo P7450 2.13GHz 4Gb Ram - Seven 64
Code: [Select]
AutoCAD 2013
;(time-it '(c:ShortLongest))   Program running time: 3822 msecs.
;(time-it '(ph:all1))          Program running time: 5024 msecs.
;(time-it '(c:Long&ShortOfIt)) Program running time: 7644 msecs.

AutoCAD 2010
;(time-it '(c:ShortLongest))   Program running time: 2028 msecs.
;(time-it '(ph:all1))          Program running time: 67174 msecs.  <<< ?   
;(time-it '(c:Long&ShortOfIt)) Program running time: 5304 msecs

I think that the real difference in performance between all versions is due to the cancellation in a single shot of all entities, the latest versions are almost similar.


Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1451
  • Marco
Re: ( Challenge ) Shortest & Longest line
« Reply #46 on: January 31, 2013, 02:47:30 PM »
New version:
Code - Auto/Visual Lisp: [Select]
  1. (defun C:ShortLongestByLyr2 ( / TblDat SelSet SelSt2 Countr EntSht EntLng
  2.                                 EntDat EntNam LenVal MaxLen MinLen AllSet)
  3.   (defun Dxf (DxfCod EntDat)  (cdr (assoc DxfCod EntDat)))
  4.   (if (= 1 (logand 1 (getvar "UNDOCTL"))) (command "_.UNDO" "_C" "_N"))
  5.   (setvar "HIGHLIGHT" 0)
  6.   (setq SelSt2 (ssadd))
  7.   (while (setq TblDat (tblnext "LAYER" (null TblDat)))
  8.     (if (setq SelSet (ssget "_X" (list '(0 . "LINE") (cons 8 (cdr (assoc 2 TblDat))))))
  9.       (progn
  10.         (setq
  11.           Countr 0
  12.           EntSht (ssname SelSet 0)
  13.           EntLng EntSht
  14.           EntDat (entget EntSht)
  15.           MaxLen (distance (Dxf 10 EntDat) (Dxf 11 EntDat))
  16.           MinLen  MaxLen
  17.         )
  18.         (repeat (sslength SelSet)
  19.           (setq
  20.             EntNam (ssname SelSet Countr) EntDat (entget EntNam)
  21.             LenVal (distance (Dxf 10 EntDat) (Dxf 11 EntDat))
  22.             Countr (1+ Countr)
  23.           )
  24.           (cond
  25.             ( (> LenVal MaxLen) (setq MaxLen LenVal  EntLng EntNam) )
  26.             ( (< LenVal MinLen) (setq MinLen LenVal  EntSht EntNam) )
  27.           )
  28.         )
  29.         (setq
  30.           SelSt2 (ssadd EntSht SelSt2)  SelSt2 (ssadd EntLng SelSt2)
  31.           AllSet (cons SelSet AllSet)
  32.         )
  33.       )
  34.     )
  35.   )
  36.   (command "_.ERASE") (foreach ForElm AllSet (command ForElm))
  37.   (command  "_R" SelSt2 "")
  38.   (setvar "HIGHLIGHT" 1)
  39. )

Code: [Select]
;AutoCAD 2010
;(time-it '(c:CAB:test))            Program running time: 2621 msecs.   
;(time-it '(c:ShortLongestByLyr2))  Program running time: 1747 msecs.

Stefan

  • Bull Frog
  • Posts: 319
  • The most I miss IRL is the Undo button
Re: ( Challenge ) Shortest & Longest line
« Reply #47 on: January 31, 2013, 03:40:45 PM »
Thank you all guys for parallel testing.
I like the numbers that came out but that means my computer needs a doctor.
Or I'll let my kids to turn it in a MineCraft machine...