gmggroup / omf-python

Python library for working with OMF files
MIT License
79 stars 20 forks source link

OMFWriter is unnecessarily slow to write meshes #43

Closed timmclennan closed 5 years ago

timmclennan commented 5 years ago

Using the reference python implementation to write collections of meshes seemed much slower that using other formats such as dumping the binary data using the numpy savez routine.

After profiling the OMFWriter call it was determined that approximately 90% of the time was taken up in validation of the elements and only 10% in writing the file. Further investigation determined that most of this time is spent in the _validate_mesh method of omf.surface.SurfaceElements and the validate method of the property array classes in properties.math.

For the _validate_mesh case, it does the numpy min/max on the omf.data.Int3Array rather than the underlying numpy array which is about 1000 times slower than it needs to be. The Vector3Array validate routine will always iterate through the array to check for direction strings even though the typical value that is being checked is a numpy array of floating point numbers.

Examples and profiles can be provided on request.

fwkoch commented 5 years ago

This should be resolved by the above two pull requests.