Author Topic: selection set "by length"  (Read 7147 times)

0 Members and 1 Guest are viewing this topic.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
selection set "by length"
« Reply #15 on: February 08, 2005, 02:03:58 PM »
My pleasure Mark. :wink:
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
selection set "by length"
« Reply #16 on: February 09, 2005, 10:10:02 PM »
Speaking of optimizing, benchmarking ... thought you might find this illuminating Mark ...

Using this benchmarking utility ...

Code: [Select]
(defun c:Test

    (   /
        GetEnameDistance
        GetEnameLength
        GetObjectLength
        ename
        object
    )

    (defun GetEnameDistance ( ename / data )
        (distance
            (cdr (assoc 10 (setq data (entget ename))))
            (cdr (assoc 11 data))
        )
    )

    (defun GetEnameLength ( ename )
        (vlax-get-property
            (vlax-ename->vla-object ename)
            'Length
        )
    )

    (defun GetObjectLength ( object )
        (vlax-get-property
            object
            'Length
        )
    )

    (setvar "cmdecho" 0)
    (command ".line" '(0 0) '(10 10) "")
    (setvar "cmdecho" 0)

    (setq object
        (vlax-ename->vla-object
            (setq ename (entlast))
        )    
    )

    (Benchmark
       '(
            (GetEnameDistance ename)
            (GetEnameLength ename)
            (GetObjectLength object)
        )
    )

    (vl-catch-all-apply
       '(lambda ()
            (entdel ename)
        )
    )

    (princ)

)

(c:Test)

Output:

Elapsed milliseconds / relative speed for 32768 iteration(s):

    (GETOBJECTLENGTH OBJECT).....1687 / 1.63 <fastest>
    (GETENAMEDISTANCE ENAME).....1985 / 1.39
    (GETENAMELENGTH ENAME).......2750 / 1.00 <slowest>
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
selection set "by length"
« Reply #17 on: February 10, 2005, 08:08:55 AM »
Now that is cool !!
I'm surprised that 'GetEnameDistance' was slower than 'GetObjectLength'.
TheSwamp.org  (serving the CAD community since 2003)

SMadsen

  • Guest
selection set "by length"
« Reply #18 on: February 10, 2005, 08:30:33 AM »
Got another result:

Code: [Select]
   (GETENAMEDISTANCE ENAME).....1234 / 1.82 <fastest>
    (GETOBJECTLENGTH OBJECT).....1390 / 1.62
    (GETENAMELENGTH ENAME).......2250 / 1.00 <slowest>

SMadsen

  • Guest
selection set "by length"
« Reply #19 on: February 10, 2005, 08:41:47 AM »
Here's an interesting observation. Given the function below, passing an object to it is slower than passing an ename:

Code: [Select]
   (defun GetCurveLength ( object )
      (vlax-curve-getDistAtPoint
        object
        (vlax-curve-getEndPoint object)
      )
    )


Code: [Select]
Object:
    (GETENAMEDISTANCE ENAME).....1219 / 1.99 <fastest>
    (GETOBJECTLENGTH OBJECT).....1484 / 1.63
    (GETCURVELENGTH OBJECT)......2047 / 1.18
    (GETENAMELENGTH ENAME).......2422 / 1 <slowest>

Ename:
    (GETCURVELENGTH ENAME).......1235 / 2.19 <fastest>
    (GETENAMEDISTANCE ENAME).....1500 / 1.8
    (GETOBJECTLENGTH OBJECT).....1781 / 1.52
    (GETENAMELENGTH ENAME).......2703 / 1 <slowest>

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
selection set "by length"
« Reply #20 on: February 10, 2005, 08:48:44 AM »
My results. Ran it twice.

Code: [Select]
   (GETENAMEDISTANCE ENAME).....1222 / 1.57 <fastest>
    (GETOBJECTLENGTH OBJECT).....1322 / 1.45
    (GETENAMELENGTH ENAME).......1913 / 1.00 <slowest>
   
   
    (GETENAMEDISTANCE ENAME).....1112 / 1.65 <fastest>
    (GETOBJECTLENGTH OBJECT).....1271 / 1.44
    (GETENAMELENGTH ENAME).......1833 / 1.00 <slowest>


PS.  I think Michael's computer has a vla bias. :)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
selection set "by length"
« Reply #21 on: February 10, 2005, 09:32:21 AM »
my results.
Code: [Select]

:: pasted 'test' strait into acad
Elapsed milliseconds / relative speed for 32768 iteration(s):

    (GETOBJECTLENGTH OBJECT).....1375 / 1.66 <fastest>
    (GETENAMEDISTANCE ENAME).....1766 / 1.29
    (GETENAMELENGTH ENAME).......2281 / 1.00 <slowest>

:: from within the vlide/vlisp console
Benchmarking .................Elapsed milliseconds / relative speed for 16384 iteration(s):

    (GETENAMEDISTANCE ENAME).....1062 / 1.97 <fastest>
    (GETOBJECTLENGTH OBJECT).....1281 / 1.63
    (GETENAMELENGTH ENAME).......2094 / 1.00 <slowest>
TheSwamp.org  (serving the CAD community since 2003)

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
selection set "by length"
« Reply #22 on: February 10, 2005, 10:49:35 AM »
Quick note --

I was running under AutoCAD 2004 and killed all other apps as well as my internet connection.

Also --

Quote from: Disclaimer
   ;;  Notes:
    ;;
    ;;      I make no claims that this is definitive benchmarking. I
    ;;      wrote this utility for my own purposes and thought I'd
    ;;      share it. Many considerations go into evaluating the
    ;;      performance or suitability of an algorythm for a given
    ;;      task. Raw performance as profiled herein is just one.
    ;;
    ;;      Please note that background dramatically affect results.

In other words, it's a guide, an indicator of performance, but as written I don't think it's a definitive work for benchmarking. Take the results with a grain a salt, switch the order of the statements being evaluated, perform several runs etc.

<gotto go, sorry to be so brief>
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst