I just register a Google Cloud free tier lately & took interested in Cloud Functions which can make me develope & 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 & 2.8Ghz CPU
exports.helloWorld = (req, res) => {
let message = getTheLottery();
res.status(200).send(message);
};
function getTheLottery(){
for(var i=0,len=10000000;i<len;i++)
{
var ticket=sha256(makeid(5));
if(ticket=='7CD743877911812A45CD7974023A2D1ACA9831C82057902A2300874A951E6E17')
return true;
}
return false;
}
The SHA256 algorithm was from here & makeid from here to generate random string
It take 40 seconds (40311ms) to complete the task, implement this code on C++ or C# add simple parallel & multithread it can easily run the task in less than 7 seconds on my average school PC with 4GB ram & i5 2.5ghz plus it has to run a OS system & few software in the background, let alone a code, when google claim it can make the code faster 75% compare to normal PC
I haven't try Azure cloud function. Assume i brought the "function" to my site & let ppl run 1000000 times, it'll cost 1657$ arcording to the calculator & 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 & the more time it run, the more it cost by SECONDS. With this money i can rent a VM with powerful GPU & run fully developed render or brute force software with maximum performance
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"?