title: How do I optimize parameters in my code?
body: <p>I have some code written in c++ that simulates a prefetcher for a CPU.  In the code I have some definitions that look like this</p>
  
  <pre><code>#define x 5
  ...
  for(int i = 0; i &lt; x; i++)
  ...
  </code></pre>
  
  <p>At the end of the simulation the simulator outputs the average access time which is a measure of how good the prefetcher did.  The performance of the prefetcher depends on x and some other similar definitions.  </p>
  
  <p>I would like to have a program that changes x, recompiles the new code, runs it, looks at the value, and based on the change in simulated access time repeats the process.</p>
  
  <p>Does anyone know of an easy way to do this that isn't manually changing values?</p>
  
  <p>EDIT: I think I need to clarify that I do not want to have to program a learning algorithm since I have never done it and probably couldn't do it nearly as well as others.</p>