I used the following sample code to test the performance of GetRandomNumber. Does this accurately represent how you are using getRandomNumber?
static void Main(string[] args)
{
DateTime startTime = DateTime.Now;
double dx = 0;
int i = 0;
while (DateTime.Now.Subtract(startTime).TotalSeconds < 1)
{
dx += (GetRandomNumber(0, 101) / 100.0f) -0.5f;
i++;
}
Console.WriteLine("{0} {1}", i, dx);
}
static Random randomGen = new Random();
static int GetRandomNumber(int min, int max)
{
return randomGen.Next(min, max);
}
This performs pretty well. It can generate more than 800,000 random numbers per second. That means it could generate more than 13000 random numbers per frame at 60 FPS, and you shouldn't be needing to generate a random number for every particle on every frame (only the newly added particles), so that should be way more than enough. I suspect something else is going on.
Edit: By the way, using a hard-coded constant in place of GetRandomNumber yields about the same performance, so GetRandomNumber is really not the bottleneck in this test code. When I run the GetRandomNumber function 5 times in each loop, I still get more than 700,000 iterations per second, meaning you could be calling GetRandomNumber more than 3 million times per second or more than 50,000 times per frame.