Presumably, you are doing this from a presentation language of some form, we have no idea what, or how! Remember that we can't see your screen, access your HDD, or read your mind - we only get exactly what you type to work with. And there are hundreds of different ways you could be doing this.
So start by looking at how you are doing it at the moment: assuming this is a .NET language, use the
Stopwatch class[
^] to time what you have at present:
Stopwatch sw = new Stopwatch();
sw.Start();
... code to do the timed operation ..
sw.Stop();
Console.WriteLIne(sw.Ticks);
This gives you a baseline to work from, and multiple stopwatches can be used to find out where you code is slow - so you can focus your efforts on speeding that up.
Do note that you may want to do the operations multiple times (several thousand) to get meaningful numbers unless you code is so slow a sundial could time it!
Until you have meaningful stats on how slow it is and where it is slow, it's pointless trying to speed anything up!