title: How do I measure how long a function is running?
body: <p>I want to see how long a function is running. So I added a timer object on my form, and I came out with this code:</p>
  
  <pre><code>private int counter = 0;
  
  // Inside button click I have:
  timer = new Timer();
  timer.Tick += new EventHandler(timer_Tick);
  timer.Start();
  Result result = new Result();
  result = new GeneticAlgorithms().TabuSearch(parametersTabu, functia);
  timer.Stop();
  </code></pre>
  
  <p>And:</p>
  
  <pre><code>private void timer_Tick(object sender, EventArgs e)
  {
      counter++;
      btnTabuSearch.Text = counter.ToString();
  }
  </code></pre>
  
  <p>But this is not counting anything. Why?</p>