There are three possible reasons you are getting poor performance:
- Inefficient code (unlikely)
- Networking issues (possible)
- Underlying data / performance issues within Xero (most likely)
So my money would be on 2 or 3 :)
The best way to narrow this down would be to try running some tests against a fresh Xero organisation like the demo company.
If you are still seeing issues with speed then it may be networking / connectivity related.
If not, then it points to a problem with the amount of data in your Xero organisation.
Be aware that Xero is designed as small business accounting software so the general guidance on system limits may not match up to the volumes you are creating if your system has large volumes of data.
If you are still struggling, getting using the Xero support resources might be a better option.