Question about instancing efficiency between vtk8.2 and vtk9.0

Hey guys, i took a test about variable instancing efficiency between vtk8.2 and vtk9.0 on different class.
Here was what i got:

testing times: 10000
Statistical method: average instancing time
the method instancing: vtkSmartPointer《class》 variable = vtkSmartPointer《class》::New();

VTK 9.0.3:
vtkGenericCell: 1.5002 us
vtkSphere: 0.0703 us
vtkSTLReader: 4.3552 us

====================================

VTK 8.2:
vtkGenericCell: 8.6075 us
vtkSphere: 0.2852 us
vtkSTLReader: 34.239 us

There are two questions for me.
FIRST, on the different version vtk, the same classes have significant instancing time that approximately is 10 times, and is there any optimizations?
SECOND, on the same version vtk, the different classes also have significant instancing time. what causes the difference?

Thanks for your reading!

1 Like

Classes can have different members. Some may take longer to initialize themselves to some initial state.

The difference between 8.2 and 9.0.3 is interesting though. Are you sure these are both built using the same configuration (e.g., 8.2 isn’t a Debug build and 9.0.3 a Release build)?

Many factors dictate the total instantiating time of a class. It is difficult to draw a conclusion based only on the execution time measurements. I recommend using a profiler to drill down the total execution time so you can have an idea of where the instantiation takes most of the time on each version. Many VTK classes are large compositions of classes. A refactoring made in version 9 can explain the difference, for example. Benchmarking code is a vast subject itself (there are entire volumes written on it) and is far more than just computing the differences of the timestamps taken before and after the call to a constructor and averaging them.

1 Like