Performance considerations

Torsten,
Under your 'performance considerations' chapter I see no comments about using the functions "command-s" and "vl-cmdf". How does their speed compare with other vl-functions? Also, do you think using vl-functions to replace e.g. (command-s "_UCS" ...) could be faster? That looks like slower to me because of a lot more instructions involved.
Have a nice day,
Jef Joris, 3+

Comments

  • Dear Jef,

    there should be virtually no performance difference, for (command), (command-s) and (vl-cmdf) ...
    the (vl-cmdf) is just special how it evaluated the arguments, upfront, from right to left ...
    while standard (command) + (command-s) evaluate from left to right, *while* (command) function is evaluation ... so errors in arguments + argument expressions will happen during (command),
    where (vl-cmdf) evaluates before :-)

    But as general approach : wherever possible, best to not use (command) :-) for performance reasons ...
    many greetings !
  • ALANH
    edited August 2022
    Old fashioned Entmake is possibly fastest depending on task, I did something for a client, got 3min 30 secs had another go, got 1 min 55 seconds, adopted entmake got like 55 seconds. Inserting 1000+ various blocks.

    Just take a step back and look at code.

    Functions like using mapcar can make significant speed improvements.

    You can compare run time of functions so work out what works best.
    https://www.cadtutor.net/forum/topic/31243-help-how-to-test-speed-of-a-function/

  • Thanks Torsten and Alanh, very helpful.
    Do you think there is a gain for speed to use vl-functions for the UCS command? And for the functions? Both command I use hundreds of times in my code.
  • Dear Jef,
    (vl-cmdf) will not provide performance advantage ver (command), it also does access the command interface.
    When creating entities, the (vla-addXxxx) functions will provide significant gain over (command) and (entmake), by factors.
    If you want to create entities aligned to a specific UCS, you might specify the (210 ...) group, in the (entmake) list, but requires to calculate the (210 ...) group based on the "arbitry axis algorithm, described on the web.

    For other massive database operations, it might help to specify transaction bracket by
    (if vle-start-transaction (vle-start-transaction))
    :
    :
    (if vle-end-transaction (vle-end-transaction))

    many greetings !
  • Dear Torsten,
    First, do you say that the vla-addxxx functions are much faster than the entmake function? It seems like AlanH claims the opposite.
    About : I was referring to the command , not to the group codes. I can find no vl..-functions for creating groups, modifying or exploding them.
    For the UCS changes, thanks for your suggestion.
    Have a nice day,
    Jef Joris, 3+
  • Dear Jef,

    yes, from all my own testing (see the Lisp benchmarks in "Lisp Developer Support Package"), (vla-addXxx) are significantly faster than (entmake) ... (entmake) is basically a kind of DXFIN operation, with intensive list data verification, and conversion from Lisp data to C++ data ... a multi-stage operation;
    (vla-addXxx) in turn creates the target entity directly, using the specified definition data.

    Managing group - indeed, so far no dedicated (vl-xxx) functions;
    besides, there are (vla-xxx) functions to modify, edit groups; and creating + deleting groups is also possible via vla/COM functions;
    just "exploding" a group is not possible :-) as it is only a logical collection/combination of entities.
    many greetings !
  • Hi Jeff,

    AlanH comments are valid in regards to AutoCAD but not for BricsCAD. BricsCAD LISP enjoys many benefits not found in Autolisp. One of them is Fast-COM
    https://developer.bricsys.com/bricscad/help/en_US/V22/DevRef/source/LISPFastCOM.htm
    This was added to support the Linux & Mac platforms that don't have COM. A side benefit on all platforms is this provides a big performance boost.

    I recommend that you take a look at the Lisp Developer Support Package (LDSP), which includes an offline version of the developer help.

    BricsCAD LISP includes the express tools "ACET" functions. there are some for working with groups
    e.g.
    ; Note. acet-group-make-anon needs to be provided a list of enames use vle-selectionset->list to convert a selection set to the desired list.
    (acet-group-make-anon (vle-selectionset->list (ssget)) "My group description")
    
    Although these functions look to be just using command calls under the hood. Groups look to be pretty involved to work with, which is probably why. See
    https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/get-group-name-of-an-entity/td-p/1526241

    Regards,
    Jason Bourhill
    BricsCAD V22 Ultimate
    CAD Concepts

  • ALANH
    edited September 2022
    Good to hear about Vla-addxxxx commands will look into that, always learning, the task with last job was 1720 blocks to be inserted with calcs, so any speed improvement is worth looking at. So could look at progression starting with Command -> Vla-insertblock, if your doing 10 of command will be instant, do 1000 then speed creeps in.

    The other problem with command is that screen will blink.

    I work both Acad & Bricscad and there is a speed diff for same code towards Bricscad.

  • Torsten, Jason, Alanh, all thanks for your comments. They were very helpful.