← Home ← Back to /g/

Thread 106396303

10 posts 4 images /g/
Anonymous No.106396303 >>106396318 >>106396408 >>106397459
while(isLoading) {
loadingBar.percentage = Math.randInt() % 100
sleep(1)
}
Anonymous No.106396318 >>106396424 >>106396427
>>106396303 (OP)
this is effectively real world code
Anonymous No.106396408
>>106396303 (OP)
so its a nonlinear loading bar, and ?
Anonymous No.106396424
>>106396318
I've implemented loading bars in the past by refactoring the entire program to use deterministic algorithms, e.g instead of using quicksort you use mergesort or radixsort and you know the exact number of iterations you're going to use, and invoke a callback to update progress. It's a giant pain in the ass and you should just show a generic loading animation with no progress guarantees if you can
Anonymous No.106396427
>>106396318
I know, I've seens it.
Anonymous No.106396943 >>106397038
>loading bar slowly creeps towards 90%
>once it's actually done loading then it zips to 100%
Anonymous No.106396983
>LOADING 100% COMPLETE
>STARTS DOING SOMETHING ELSE THAT TAKES AN ADDITIONAL 5 SECONDS
Anonymous No.106397038
>>106396943
They wait for operations, instead of processing chunks: Easier.

For example:
I need to copy 10 files of different sizes.
It speeds up the code significantly if I copy them in the easiest way possible and add 10% for each file copied.

Calculating the total size of the files and copying them partially in chunks of, say, 1MB, and updating the progress every 1MB, will make the progressbar smoother, but the code will be verbose: A bad tradeoff
Anonymous No.106397459
>>106396303 (OP)
>while(loadingBar.percentage = floor(Math.rand())) {
sleep(1)
}
Anonymous No.106398924
>loading bar starts going backwards