示例#1
0
    def testCollaboratePerf(self):

        # Set up a scene with lots of spheres with different UVs
        uvSphere = GafferScene.Sphere()
        uvSphere["divisions"].setValue(imath.V2i(2000))
        uvSphere["expression"] = Gaffer.Expression()
        uvSphere["expression"].setExpression(
            'parent["transform"]["translate"]["y"] = 2 * int( context["collect:rootName"] )'
        )

        camera = GafferScene.Camera()
        camera["projection"].setValue('orthographic')

        parent = GafferScene.Parent()
        parent["parent"].setValue('/')
        parent["children"][0].setInput(camera["out"])
        parent["in"].setInput(uvSphere["out"])

        sphereFilter = GafferScene.PathFilter()
        sphereFilter["paths"].setValue(IECore.StringVectorData(['/sphere']))

        mapProjection = GafferScene.MapProjection()
        mapProjection["in"].setInput(parent["out"])
        mapProjection["filter"].setInput(sphereFilter["out"])
        mapProjection["camera"].setValue('/camera')

        collectScenes = GafferScene.CollectScenes()
        collectScenes["in"].setInput(mapProjection["out"])
        collectScenes["rootNames"].setValue(
            IECore.StringVectorData([str(i) for i in range(50)]))

        allFilter = GafferScene.PathFilter()
        allFilter["paths"].setValue(IECore.StringVectorData(['/...']))

        # Set up query
        query = GafferScene.UDIMQuery()
        query["in"].setInput(collectScenes["out"])
        query["filter"].setInput(allFilter["out"])
        query["outInt"] = Gaffer.IntPlug()
        query["outIntExpression"] = Gaffer.Expression()

        query["outIntExpression"].setExpression(
            'parent["outInt"] = len( parent["out"] ) + context["iteration"]')

        with GafferTest.TestRunner.PerformanceScope():
            GafferTest.parallelGetValue(query["outInt"], 400, "iteration")
示例#2
0
    def testExceptionDuringParallelEval(self):

        # This only caused a problem when using GAFFER_PYTHONEXPRESSION_CACHEPOLICY=TaskCollaboration
        # with a TaskMutex without a properly isolated task_group so that exceptions in one thread
        # can cancel the other.  We're adding a more specific test for this to TaskMutex, so we're not
        # expecting this to catch anything, but it's still a valid test

        m = GafferTest.MultiplyNode()

        m["e"] = Gaffer.Expression()
        m["e"].setExpression(
            inspect.cleandoc("""
			if context["testVar"]%10 == 9:
				raise BaseException( "Foo" )
			parent['op1'] = 1
			"""))

        with six.assertRaisesRegex(self, BaseException, "Foo"):
            GafferTest.parallelGetValue(m["product"], 10000, "testVar")
示例#3
0
    def testPerformance(self):
        c = Gaffer.ContextVariables()
        c.setup(Gaffer.IntPlug())
        for i in range(10):
            c["variables"].addChild(
                Gaffer.NameValuePlug("a%i" % i,
                                     IECore.StringData("A" * 100),
                                     flags=Gaffer.Plug.Flags.Default
                                     | Gaffer.Plug.Flags.Dynamic))
        c["variables"].addChild(
            Gaffer.NameValuePlug("intName",
                                 IECore.IntData(100),
                                 flags=Gaffer.Plug.Flags.Default
                                 | Gaffer.Plug.Flags.Dynamic))

        # This would be a bit more representative if our source node was actually affected by the context variables,
        # but without access to OSL in this test we don't have any efficient way to read context variables handy,
        # and we're mostly just interested in the amount of overhead anyway
        n = GafferTest.MultiplyNode()
        c["in"].setInput(n["product"])

        GafferTest.parallelGetValue(c["out"], 1000000, "iter")
示例#4
0
    def testContentionForOneItem(self):
        m = GafferTest.MultiplyNode()

        GafferTest.parallelGetValue(m["product"], 10000000)