title: Why does Cloud Functions perform so low yet so expensive?
body: <p>I just register a Google Cloud free tier lately &amp; took interested in Cloud Functions which can make me develope &amp; run code without install OS system or Software Development Tools. So i want to test its performance to its limit with this function run on set up of 2GB &amp; 2.8Ghz CPU</p>
  
  <pre><code>exports.helloWorld = (req, res) =&gt; {
    let message = getTheLottery();
    res.status(200).send(message);
  };
  
  function getTheLottery(){
  for(var i=0,len=10000000;i&lt;len;i++)
  {
  var ticket=sha256(makeid(5));
  if(ticket=='7CD743877911812A45CD7974023A2D1ACA9831C82057902A2300874A951E6E17')
       return true;
      }
      return false;
  }
  </code></pre>
  
  <p>The SHA256 algorithm was from <a href="https://geraintluff.github.io/sha256/" rel="nofollow noreferrer">here</a> &amp; makeid from <a href="https://stackoverflow.com/questions/1349404/generate-random-string-characters-in-javascript">here</a> to generate random string</p>
  
  <p>It take 40 seconds (40311ms) to complete the task, implement this code on C++ or C# add simple parallel &amp; multithread it can easily run the task in less than 7 seconds on my average school PC with 4GB ram &amp; i5 2.5ghz plus it has to run a OS system &amp; few software in the background, let alone a code, when google claim it can make the code faster 75% compare to normal PC</p>
  
  <p>I haven't try Azure cloud function. Assume i brought the "function" to my site &amp; let ppl run 1000000 times, it'll cost 1657$ arcording to the <a href="https://cloud.google.com/products/calculator/#id=33a2fc67-04ba-43a9-8877-aadb5846d5ef" rel="nofollow noreferrer">calculator</a> &amp; maybe a fortune to run it few hundreds time for a full day with barely any way to optimize the code or system since it's all limited &amp; the more time it run, the more it cost by SECONDS. With this money i can rent a VM with powerful GPU &amp; run fully developed render or brute force software with maximum performance</p>
  
  <p>Is there any better way for me to run the code? 'cause this feel like a online code compiler with extra steps. How does it make serverless computing the "future"?</p>