Giter Club home page Giter Club logo

Comments (6)

mottosso avatar mottosso commented on July 20, 2024

Thanks for reporting this. I'm glad you consider the performance impact of your suggestions. :)

What I would suggest is that you profile the change, before and after, identify what the cost is and if it's "too much" then we could find a way to work with that; e.g. either make it optional, or add a stern warning in the documentation.

To profile things like this, have a look at plot.py for inspiration.

from cmdx.

wougzy avatar wougzy commented on July 20, 2024

looks like it's safe. i ran several loops of 20000 parent commands and the difference between with or without is notable but still very small (about 50ms vs 200ms for each packet)

from cmdx.

mottosso avatar mottosso commented on July 20, 2024

If you can fit your test in plot.py, ideally using a similar/same convention, then that would be swell. Then you could make a note of how long it takes along that line, for anyone looking at this in the future wondering how costly that is. You'll find similar notes across the code, in a μs unit, for microseconds.

from cmdx.

wougzy avatar wougzy commented on July 20, 2024

hmm ok i see! here are more serious results (: is that what you had in mind?

New()

root1 = cmdx.createNode("transform")
root2 = cmdx.createNode("transform")
child = cmdx.createNode("transform", parent=root2)

melparent = 'parent -r "transform3" "transform1"; parent -r "transform3" "transform2";'
Test("mel", "parent", lambda: mel.eval(melparent), number=1, repeat=1000)
Test("cmds", "parent", lambda: [cmds.parent("transform3", parent, r=1) for parent in ("transform1", "transform2")], number=1, repeat=1000)
Test("cmdx", "parent", lambda: [cmdx.parent(child, parent) for parent in (root1, root2)], number=1, repeat=1000)
Test("cmdx safe", "parent", lambda: [cmdx.parent(child, parent, safe=True) for parent in (root1, root2)], number=1, repeat=1000)
root1, root2, child = pm.ls(map(str, (root1, root2, child)))
Test("PyMEL", "parent", lambda: [pm.parent(child, parent, r=1) for parent in (root1, root2)], number=1, repeat=1000)
parent mel: 115.5 ms (109.30 µs/call)
parent cmds: 119.1 ms (114.50 µs/call)
parent cmdx: 11.1 ms (10.60 µs/call)
parent cmdx safe: 19.3 ms (18.30 µs/call)
parent PyMEL: 601.7 ms (583.70 µs/call)

it looks like adding this security costs about twice the original command. still way cheaper than mel/cmds though

from cmdx.

mottosso avatar mottosso commented on July 20, 2024

Oh you are a star. :D Thanks for putting a smile on my face.

Yes, that is exactly what I had in mind. That safe= option is great, we could leave that in, and default it to True. That way, anyone wanting to squeeze performance could toggle that flag, and they'd be good to go.

from cmdx.

mottosso avatar mottosso commented on July 20, 2024

Implemented in #24. Thanks @wougzy!

from cmdx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.