title: How do i calculate execution time of an algorithm in React-Native?
body: <p>I have a thesis going on regarding comparisons between Swift and React-Native. For the performance of both languages i compare basic algorithms such as Sieve and recursive fibonacci.</p>
  
  <p>I have implemented recursive fibonacci in a react project and now I want to time the algorithm's execution time.</p>
  
  <p>Here is my code so far:</p>
  
  <pre><code>const App: () =&gt; React$Node = () =&gt; {
  
    var num = 20;
    let time1;
    let time2;
    let executionTime;
    var fibNum;
  
    return (
      &lt;View style ={{flex: 1,
        justifyContent: "center",
        alignItems: "center",
        margin: 8,
        }}&gt;
  
  
      &lt;Text style = {{fontSize: 24}}&gt; {fib_run(num)} &lt;/Text&gt;
      &lt;Text style = {{fontSize: 18}}&gt;Time it took was {executionTime} ms&lt;/Text&gt;
  
      &lt;/View&gt;
    );
  
  
    function fibonacci_rec(num){
  
      if(num &lt;= 1)
      return 1;
  
      return fibonacci_rec(num - 1) + fibonacci_rec(num - 2);
    }
  
  
    function fib_run(num){
  
      time1 = new Date().getMilliseconds();
      fibNum = fibonacci_rec(num);
      time2 = new Date().getMilliseconds();
      executionTime = (time2 - time1);
  
      return fibNum;
    }
  
  
  };
  
  </code></pre>
  
  <p>For some reason the executionTime variable always shows 0.
  How do I solve this?</p>
  
  <p>(I have very little knowledge in React-Native)</p>
  
  <p>Kind regards, Stefan</p>