0

I'm working on a program where the main entities are mathematical equations. Equations can only return a double or a boolean result.

The problems:

1- Lots of equations. (~300 per file)

2- There has to be a computations-log at the end, so every equation should somehow be able to log itself.

3- It has to be fast, as fast as possible, because those few hundred equations could be triggered a million times. (Think of it as a big optimization loop).

4- I want to enforce a certain order of appearance for the logged equations that is not necessarily similar that of the code.

Currently, I'm using C. (or C, with a little bit of C++), and writing every equation as a function-like macro. I'm wondering though if this is the right way to go. Has this kind of problems been tackled before? Is there some other language that's better suited to this than C? And is there any design patterns or practices that I need to be aware of for this specific class of problems?

Mohamed Tarek
  • 385
  • 3
  • 11

1 Answers1

0

So the equations are turning into compiled code, not interpreted? If so, that's the fastest.

However, if your logging involves I/O, that might be the biggest time-taker, which you can determine for sure by turning it off and comparing execution time. If so, possible ways around it are:

  • generating output in binary, rather than formatting numbers.

  • not writing any more than you have to, like events rather than long records.

  • trying not to be rotary-disk-bound, like writing to a memory file or a solid-state disk.

Mike Dunlavey
  • 40,059
  • 14
  • 91
  • 135
  • Thanks. The main problem though is how to properly log the calculations themselves, and whether there's already some solid model that's been devised for this class of problems. – Mohamed Tarek Nov 20 '12 at 15:26