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

Method test

test/IECore/VectorData.py:1273–1322  ·  view source on GitHub ↗
( self )

Source from the content-addressed store, hash-verified

1271
1272 @unittest.skipIf( os.environ.get("TRAVIS", False), "'TRAVIS' env var defined - skipping unreliable test" )
1273 def test( self ) :
1274
1275 d = IECore.IntVectorData( 100 * 1024 * 1024 )
1276
1277 t = IECore.Timer()
1278 h = d.hash()
1279 firstTime = t.stop()
1280
1281 t = IECore.Timer()
1282 h2 = d.hash()
1283 secondTime = t.stop()
1284
1285 self.assertEqual( h, h2 )
1286 # hash computation should be cached the second time, so should be much faster
1287 self.assertLess( secondTime, 0.001 * firstTime )
1288
1289 d2 = d.copy()
1290 t = IECore.Timer()
1291 h2 = d.hash()
1292 secondTime = t.stop()
1293
1294 self.assertEqual( h, h2 )
1295 # cached hash should have been transferred to the copy, so also should be much faster
1296 self.assertLess( secondTime, 0.001 * firstTime )
1297
1298 d[0] = 10
1299 t = IECore.Timer()
1300 hm = d.hash()
1301 secondTime = t.stop()
1302
1303 self.assertNotEqual( h, hm )
1304 # should be slow this time, as the hash is being recomputed
1305 self.assertGreaterEqual( secondTime, 0.7 * firstTime )
1306
1307 t = IECore.Timer()
1308 h2 = d2.hash()
1309 secondTime = t.stop()
1310
1311 self.assertEqual( h, h2 )
1312 # cached hash should remain in the copy, so should still be much faster
1313 self.assertLess( secondTime, 0.001 * firstTime )
1314
1315 d2[0] = 10
1316 t = IECore.Timer()
1317 hm2 = d2.hash()
1318 secondTime = t.stop()
1319
1320 self.assertEqual( hm, hm2 )
1321 # should be slow this time, as the hash is being recomputed
1322 self.assertGreaterEqual( secondTime, 0.8 * firstTime )
1323
1324class TestInternedStringVectorData( unittest.TestCase ) :
1325

Callers

nothing calls this directly

Calls 4

stopMethod · 0.95
TimerMethod · 0.80
hashMethod · 0.45
copyMethod · 0.45

Tested by

no test coverage detected