Jul 15, 2020 03:51
@rexfordkelly Those were my thoughts aswell. Very interesting benchmarks tho.
Jul 15, 2020 03:51
@rexfordkelly pastebin.com/q9pRNKwv This gives:Loop: loopForIndexed: 0.120ms Loop: loopAnonIndexed: 0.090ms Loop: useForEach: 0.070ms Loop: loopForEach: 0.045ms loopForIndexed250loopAnonIndexed500useForEach2000loopForEach‌​1 which suggests useforeach is more than 4 times faster than anonindexed which is second fastest.
Jul 15, 2020 03:51
@rexfordkelly Hmm. We do get different results tho. I have it setup like this: var j = 0;string += "loopForIndexed"; console.time("Loop: loopForIndexed"); loopForIndexed(sampleSize); console.timeEnd("Loop: loopForIndexed"); string += j; for each benchmark. In the loops there j++; added to noop and inside the for loop.
Jul 15, 2020 03:51
@rexfordkelly the declarations were made outside of the benchmarks in the second case. Seems like the useForeach is around 4 times faster than any other and the last is not even running. Only thing added inside the benchmarks was j++; Might be that last one is running somehow async tho.
Jul 15, 2020 03:51
@rexfordkelly loopForIndexed times run: 500 loopAnonIndexed times run: 500 useForEach times run:1000 times run:loopForEach times run: 1. I switched to counting how many iterations were done. Benchmarks are as follow : Loop: loopForIndexed: 0.115ms Loop: loopAnonIndexed: 0.130ms Loop: useForEach: 0.050ms Loop: loopForEach: 0.065ms
Jul 15, 2020 03:51
Soo it's extra var j = 0; before each function call and string += j; after them and j++; inside noop and iterators. Just to check they run properly.
Jul 15, 2020 03:51
well I put a string += "e"+e+"i"+i+"c"+c; in the noop function and string +="loopname"; to each of those function calls then last console.log(string); I get all the function names followed by nothing. Then after useForEach I get 3.9million characters. Then after that the loopForEach but nothing concatenated.
Jul 15, 2020 03:51
@rexfordkelly well only loop running in snippets is the useforeach which gets run about 1000*1000 times. I put a string to test those loops and concatenated, only that loop produces about 3.9million characters while others do nothing.
Jul 15, 2020 03:51
@rexfordkelly well the functions don't run as you say they would. You pass a number 1000 to the first function etc...
Jul 15, 2020 03:51
I just did console log in the loopAnonIndexed inside the "anonymous" loop function and there's really just one console log. On the other hand the console.log adds about 4 times the execution time of without console.log. Those loops don't work in snippets?
Jul 15, 2020 03:51
Umm, the cb is undefined in the snippet tbh and it shows it's only ran once I think.
Jul 15, 2020 03:51
What happens if you call them multiple times? Do they still get outperformed?
 
Jan 11, 2018 10:12
You just keep picking on that while loop. It's fixed as you would say
Jan 11, 2018 10:12
You haven't met employer that changes it's mind to what they want the code to do? Wow, but point taken. I'm don't code like you describe me to code. That was just an example trying to help out with the actual problem
Jan 11, 2018 10:12
You should at least explain to me how using a while while fetching query row's is going to change my thinking for the worse and make my code " slower, poorly coded and less reliable"
Jan 11, 2018 10:12
What is your problem it's way more readable when you have to read thousands of lines of queries and php and don't have to look for that one that doesn't have while
Jan 11, 2018 10:12
Might be far fetched, but try to add value="1" for that button. Just a suggestion
Jan 11, 2018 10:12
Well there's only 2 actual cases here. if(isset($_POST['login'])) or the attempt count isn't retrieved from the database
Jan 11, 2018 10:12
Might be a dumb question, but is the POST['login'] set? Meaning you have a field named "login" in the form you are sending to that php
Jan 11, 2018 10:12
I use while because when you first write it you expect one result. But you might change it for whatever reason and it's not heavier to run with while
Jan 11, 2018 10:12
header("Location: /ase/index.php?url=locked"); how about this?
Jan 11, 2018 10:12
There's a leak, some unclosed { bracket
Jan 11, 2018 10:12
I can't comment yet, so answering was the only solution