You could profile your code to find out where exactly is the bottleneck.