Hi everybody,
I'm building a Monte Carlo simulation - not a gambling site, but a type of model that runs millions of times using a random number generator to pick a value for independent variables from a probability distribution that are then used in other calculations.
The inner loops of the model run millions of times and have to be blazingly fast or the model will take weeks, even months to run. We're writing the application in C# and I'm afraid that the overhead of the interpreter from intermediate code into machine code will be a killer.
Any suggestions as to a language I can use for the inner loops that compiles into fast machine code whose object code I can link back into the C# code?
Many thanks, Ned
Advice on very fast execution
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Mike GoldRank #50 · 30.6K pointsPosted May 2, 2007, 10:27 AM EDT
Are you trying to get a pure random number after millions of random generations or are you getting a million random numbers?
If you just want a loop that generates random numbers, why not spin it in a thread with some sort of sleep delay and have it run in parallel?
If you are looking for a more "random" random number, you can use the DateTime.Now.Ticks as a seed.
Ned Goodhue3 pointsPosted May 3, 2007, 6:23 AM EDT
The problem is that this code has to run millions of times. If that code is going to be interpreted from intermediate code to machine code each time it runs, it will be too slow. I need this inner loop to be compiled down to machine code by a machine-specific compiler then linked into the C# shell.
I'm trying to figure out how best to do that.
Mike GoldRank #50 · 30.6K pointsPosted May 3, 2007, 9:11 AM EDT
The only slow down may be garbage collection of large data.