MCPcopy Create free account
hub / github.com/ImageEngine/cortex / testCopiedDataReferences

Method testCopiedDataReferences

test/IECore/MemoryUsage.py:69–88  ·  view source on GitHub ↗

Copied data shouldn't use additional memory unless the copies have been modified by writing.

( self )

Source from the content-addressed store, hash-verified

67 self.assertTrue( c.memoryUsage() < m + dm )
68
69 def testCopiedDataReferences( self ) :
70
71 """Copied data shouldn&#x27;t use additional memory unless the copies have
72 been modified by writing."""
73
74 c = IECore.CompoundObject()
75 d = IECore.IntVectorData( 10000 )
76
77 c["a"] = d
78 c["b"] = d.copy()
79
80 c2 = IECore.CompoundObject()
81 c2["a"] = d
82 c2["b"] = d
83 self.assertTrue( abs( c.memoryUsage() - c2.memoryUsage() ) < 10 )
84
85 # writing to the copy should now increase the memory usage
86 m = c.memoryUsage()
87 c["b"][0] = 100
88 self.assertTrue( c.memoryUsage()!=m )
89
90if __name__ == "__main__":
91 unittest.main()

Callers

nothing calls this directly

Calls 3

memoryUsageMethod · 0.95
CompoundObjectMethod · 0.80
copyMethod · 0.45

Tested by

no test coverage detected