Without the code or any idea of how you are doing that, we can have no idea how to help you - and you need to do some preparatory work before we could begin to help anyway.
This first thing you need to do is establish a baseline. Use the
Stopwatch class[
^] to time accurately the actual code, and do teh same job three or four times to get a good avaerage value. You now have a value to work from to evaluate any changes.
Now add more Stopwatch instances to narrow down which part(s) of the code are taking time, so you can concentrate on those. For example, if one loop takes 0.75 seconds and another takes 0.001, it's pointless looking at the second at all!
Continue adding Stopwatches until you have a solid base of data about where you code is slow, and it may be obvious what you need to do. If not, you know which section(s) to show us and explain just how slow it is ...
But the chances are the server is busy doing other things and your dev machine isn't.