Why are Progress Bars Always Wrong? Progress Bar Example in C.

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey everybody welcome back today i'm going to show you how to put progress bars in your terminal programs and also we're going to talk a little bit about why progress bars in general are so bad welcome back folks i hope life is treating you well today i want to talk about progress bars not because they're particularly challenging or even in all that interesting technically but because they do provide some important lessons that i think every programmer would do well to remember before we get into it source code for this video and others is available through patreon also i love hearing from you that you enjoy this content if you are enjoying this content please like the video subscribe to the channel it really helps out okay so about progress bars unless you've been living under a rock you've seen a progress bar anytime we're doing anything in software that takes a certain amount of time so long processing downloading things we're gonna see a progress bar and they're pretty much all bad well i mean not bad bad is the wrong word to use they're inaccurate they tend to not give you an accurate view of where they are in their process and how much time you have left they may for example tell you you're halfway done and you're almost done or they may tell you you're halfway done and you have a lot left to do and it's really funny when people find out what i teach and what i do this is people outside the field often the question that they ask is hey what about those progress bars why can't you fix that so that they're accurate and so i thought today would be fun to do a video about progress bars and i thought we could just talk about what's going on but i think it's more my style and more in line with what we do on this channel to dive into code and actually build one and look at what it's like to actually put a progress bar into one of your programs so i'm going to show you how to make a progress bar for your terminal programs and through this process hopefully we'll learn a few things we'll be able to talk about a few things and hopefully you'll come out on the other end a better programmer so let's jump into the code okay so here's a simple starter program it doesn't really do anything yet also i have a simple make file over here it's pretty typical all it does is compile this program now all i want to do initially for this program to do is to periodically update a status bar okay so a progress bar so let's start by making a simple loop in here what we're going to do is just let's make a for loop and let's go from 0 to 100 and actually i want to go all the way to 100 so let's add greater than or equals and let's increment it okay and then each time through the loop i want to call a function that's going to update my progress bar let's just call it update bar okay update bar and we'll pass in our i so basically say we want to update the progress bar with a particular percentage it's going to be some number between 0 and 100 and then just so we can see what's going on i'm going to wait a little while so let's just use you sleep or micro sleep and sleep let's give it 20 000 so that's should be 20 milliseconds it should be enough that we should be able to see what's going on it should slow things down and we should be able to see things we can always adjust it later if that's not enough time okay so simple enough now we need to of course implement this little progress bar function so let's come up here and i want to start out by making this as simple as possible okay so we could get fancy we could add colors we could use curses to place the progress bar some place like on the top left or bottom right you know bottom right we could put it in a fixed location on the screen today i'm not going to really do that let me know down in the comments if you'd like to see videos on getting a little more fancy with progress bars but for today i'm just assuming that your program is doing something maybe a long download or something and we just want to stick a progress bar on the current line that's going to grow until our task is completed okay so first of all let me just come in here and make a constant or const int and let's say it's going to be the length of our progress bar okay let's let's make it 30 characters i can adjust this to whatever i want but let's just let's start with 30. and then let's come down here and make our function our update bar function bar not bar i'm going to return void because this just updates the progress bar it doesn't really do anything and i'm going to take in a single integer we'll call it percent done okay now in here really what we're going to do is we're just going to we need to print out a progress bar and keep in mind that i could pass in a double which could be a fraction from zero to one that would work perfectly too i'm just choosing to work with integers but feel free to change this according to your own style and you know your own program how you want it to work okay so now what i'm going to do here is i need to figure out how many of my 30 characters should be marked as done or filled in okay so let's make a variable called num cares and what i'm going to do is i'm going to take percent the percent done basically this is the percentage of the 30 characters that i want to be filled in and we'll just multiply that by the progress bar length and divide it by 100 so notice i'm multiplying first and dividing because these are integers and so if i go the other way around i'm likely to zero stuff out i'm going to get this floor effect if i divide everything by a hundred it's all going to be zero and then you multiply that by the progress bar length and our progress bar isn't going to grow okay so now we know how many characters we want to print out now really simply all i'm going to do here is let's let's start off our line with a open square bracket and then let's go down and let's just make a for loop that is going to we're going to go for the number of characters aaron i'm going to add an s here just so i keep saying characters um and let's increment i and then for each of these all i'm going to do is just print out a pound sign okay so the idea here is that the pound sign is representing how you know that a a particular part of the progress bar is full or done uh you could use whatever character you want i'm just using the pounds line because it kind of has this square kind of fills in the space so it's going to look like a bar okay and then down here i also need to finish it up but now we've done the first part of it so let's make another for loop and and this is for how many non-full entries there are and so let's just do our bar length minus num cares okay so this is how many basically we have not finished and i'm gonna make this a space again feel free to change these characters to do whatever you want aesthetically with this progress bar and then down here once we're done what i'm gonna do is say print f let's close our square bracket i want to use the square brackets to make it look like a bar and then let's also just print out the the actual percentage okay this you see this sometimes let's say you know 50 done 20 done whatever and let's pass in here our percent done so this is going to close off the end of our progress bar and print out what percentage done we are now at this point we can go ahead let's come down here and at this point we should be able to compile our program okay so we can make it and we can run it and you can see that it does actually fill in the bar as we go up and of course right now you're saying hey that's not a progress bar that's just printing out something that looks like a progress bar on a bunch of different lines yeah i know but i wanted to get this in place first so now let's go back to our code and we'll make it grow in place and to make it grow in place is really really simple now i'm going to make a few little changes to my program the first is i'm going to come down here and i'm going to remove the new line and then i'm going to come up here and add a carriage return to the very beginning okay now what does this do the new line tells the computer or the terminal really to jump to a new line after each progress bar now we don't want to do that we want to stay on the same line now the carriage return the whole idea of a carriage return comes from old typewriters and teletype machines and it literally means return the carriage or the cursor to the start of the line so now we're saying just jump back to the start of the line the same line we've been printing on and we're going to print out things again over the top of our last line okay so once we've done this now we can come in we can compile it again and now if we run it well that didn't work so well okay it basically said nothing and then all of a sudden it said 100 and the problem here is that standard out is buffered okay so this is for speed reasons but basically the stuff we print a standard out isn't actually pushed to the screen immediately and this might behave differently on different machines different operating systems but on my machine right now it's saying you know i haven't seen a new line character yet so i'm guessing that jacob's still working on the current line so i'm not going to actually print it out yet and we can fix that by coming down here and simply each time we do this we're going to just run flush i'm going to call that flush sorry um with standard out and what this means is anything you got buffered just write it all right now so take all the buffered stuff flush that buffer out to standard out and now if we compile it and if i save it and if we come down and compile it and we run it then you notice now that it does actually move the way we would want it to so we get the progress bar effect that we're looking for now of course we do see this odd percent character here at the end that's because we didn't get a new line at the end ever and so what i'm going to do is come down here and just after we're done with this whole progress bar thing i'm going to just add a new line and now we should get what we want basically a growing progress bar and then it gives us that new line and we don't get that little percent sign there at the end okay so now we have a working progress bar and this one actually seems to work pretty good it grows steadily over time and it seems accurate and that's because we aren't really doing anything real with it yet okay so now at this point we're gonna change up our example a bit and make it more interesting now what i would like to do here there's a bunch of things we could do but what i'm gonna do is we're gonna do a bunch of downloads okay so it's similar to what a lot of installer programs do they have a bunch of different packages they're gonna download and install and in this example i'm not really gonna install anything but we are going to download some stuff so let's take our program right here and what i'm gonna do here is just drop in a bunch of urls okay there's nothing fancy about this it's just an array of character pointers and i've got a bunch of urls these are just arbitrary urls downloading things of different sizes mostly images videos and there's one cd image of it's an iso for debian okay so that one's gonna be pretty big we're gonna come back to that now it doesn't really matter you could replace this with whatever urls you wanted to download and then down here i simply just have my number of urls which is going to be the size of my whole array divided by the elements so this just basically allows me to not have a constant up here that defines my number of urls i can just basically add as many urls to this as i want and this num urls variable will be appropriately set okay now what i want to do is actually make a function that's going to download a url okay because that's what we really want to do here so what i'm going to do is come up here and let's let's return a bool just maybe in case there's failures we can we can return an error and let's pass in one argument which is going to be our url it's gonna be a character pointer okay now i'm gonna use lib curl for this i did a previous video on lib curl it's just a library that i find really useful for quick and simple networking without a lot of socket calls so i'm going to use it here if you haven't seen this and you want to check it out i'll put a link down in the description to the previous video in case you missed it so for this function right now we're going to take an argument and i'm actually i'm actually going to pass in a second argument here um let's it's going to be a struct and let's actually go up here and we're going to create this struct really quick before i forget now the reason for this is that eventually during our downloads i'm going to want to update some things i'm going to want to keep track of information and i don't want to use global variables so i'm going to make a struct and we're going to call it status info and for right now all i'm going to have in here is is a number of bytes okay so i'm going to use this so that i can pass this into different functions and i can keep track of how many bytes we've downloaded so that'll come in later on so then down here in my download struct i'm also going to pass in a status info pointer yeah so this basically allows me to pass in some of this counter information allows me to update it in this download url function okay now aside from this things are really going to be easy we're just going to say we're going to create a handle to a curl object and call curl easy and knit that starts things up at the end we're going to use curl easy cleanup pass in our handle okay so this is basically our initialization and our setup and then throughout let's just say like okay so if we were not able to get our handle well actually i don't need let's just return false okay so things basically failed down here at the bottom if everything went well we're going to return true and then really basically anytime we're using curl we're going to set some options and then we're actually going to do the download okay so let's start by setting a few of our options so you set opt pass in our handle and the option we want to set the first one obviously is going to be the curl url or sorry it's curl opt url and that's going to be the url that we passed in so that's the thing we're actually trying to download okay now the next one i want to do when i set is my write function and we're going to need a function for this right now i haven't written it yet so let's say it's like got data something like that okay and then let's also pass in because we're passing around this status info let's also pass in let's do our right data option so what that what this is saying is when i call your got data function when you actually get data that you downloaded i want to pass something in and we're going to pass in this s info pointer okay you can pass in anything you want or really a pointer to anything you want but in this case this is what i want to pass in and then let's add one more in here and this is really just for convenience let's add follow location and set it to one what this is going to do is it's going to say if i pass in a url that has a redirect and a lot of those urls that i picked actually do have redirects they're redirecting you from one url to another and i don't want to be bothered by having to figure out where all the redirects go so what this says is if there's a redirect just follow that redirect and grab whatever's on the other side okay now let's come down here and actually do the download so what's gonna happen let's see curl code this is gonna look just like i did in my previous video but we're gonna have a result value it's gonna tell us if it succeeded and then we're going to perform the operation pass in our handles so this is going to take all those options that we set up and actually use them to do a download and then if our result is not equal to curl okay then we're going to return false okay actually let's do a little cleanup here so let's yeah let's make sure we clean up curl as well right here and then if we're done then we just clean up and we're done okay so so actually since we're not doing anything really with it um let's just say let's let's trim this down a little bit and say curl easy cleanup because we're always gonna do that and then we're going to say return result equals curl okay okay so normally if we were actually doing something with the data maybe this is where we would do it right now we're just downloading it we're saying do your thing and then when we're done we're going to return true or false okay so this is going to work we still we have a few things we need to do like this gut data function doesn't exist so let's come up here and write that so let's return a size t that's what these curl functions look like call it got data and we're going to pass in a buffer this is going to actually have the data that we are receiving and it's going to have a couple of sizes the the size of our items it's going to have another which is our num items so the number of items that we actually retrieve typically this is going to be the number of items gonna be the number of bytes and the item size is gonna be one but it's not guaranteed to be that way so we need both of them now we're also gonna pass in a void pointer which is we'll call this st info this is my status info the stuff that i passed in down here in this write data argument right so i pass in s info that's going to show up right here in this pointer now it is void pointer i may actually want to use it we'll do that later but for now for now let's just say because i'm going to eventually want to use this so let's call this status and we'll set that equal to st info okay so that's just telling this function hey i want a pointer that i can actually use to reference whatever's inside but i'm not going to do anything with it right now so let's just return item size times the num items now this just tells curl that i processed the data like i actually did receive that many bytes and it tells it go ahead and keep getting more data and there's a lot more we're going to do in this function except for right now all i want to do is to add i'm going to basically just keep track of how many bytes we've received so what i'm going to do let me change this up actually just a little bit and say size t i'll just call this bytes so i don't get confused and let's just copy this or we'll cut it and we'll grab that we'll return bytes here but before we do that we're going to also say status total bytes plus equals bytes okay so this is going to add to the number of bytes we've received so far so that's going to keep track of how many bytes we've downloaded it's gonna come in handy okay so now let's go down and update things in main so if we come down here we're going to create a status info struct call it s info call it whatever we want and s info dot total bytes we're going to start as zero because we haven't downloaded anything okay so we've created this we've set set things up now let's change things up a little bit and change up this loop down here and change our bars so we'll start it out as zero okay and then in my loop every time now instead of going from zero to 100 i'm going to go up to num urls so now we're just going to go through each url and we want to actually download them so what i'm going to do is download url we're going to pass in the appropriate url the one that the ice url and then i'm going to pass in s info okay so i'm basically just saying hey this status info that i created give it a pointer update that with the status information that you get okay and then down here we need to update our bar if we do this we're just gonna get like zero percent one percent two percent that's not what we want also let's just delete this you sleep down here we don't need it anymore but yeah so we need to update this we need to update the bar now so it actually takes into account the progress on what we're working on so like let's start with a really just kind of silly almost stupid approach but what we're going to do is let's just start by saying okay let's take i plus one we're going to multiply it by a hundred we're just gonna get the percentage of the urls that we have in our list how many of those we've downloaded we're gonna divide this by num urls all right so in this case basically like when we're when we've done half the urls we're going to say 50 right simple enough and at this point i think we should be in a position where we can compile our code oh i did forget something yes i forgot in my make file to go in here and actually link with lib curl so let's take care of that that should take care of us okay so now we can compile it and we can run it and basically what you're going to see now is it jumps up pretty quick 20 forty percent as it finishes and then we get to this sixty percent done and we're just gonna hang out right we're gonna sit here for a long time uh because we have a really big download in here you know our debian image is taking up a lot of bytes in fact let's let's just cancel this and let's jump in and try to make this a little easier one thing i'm going to do is we've already come in here where we're updating so instead maybe we could we we have this total byte so so maybe in my upload or update bar let's also pass in a status info here so we'll pass in our status here and i'm going to do one more thing i'm going to say let's just print out let's print out an integer and it's going to be our number of bytes and this this will at least just like give us an idea of where we're at and how far we've gone and we'll pass in our total bytes okay so again oh what did i mess up oh i forgot to change how i call it down below so now we have to pass in status info there and we'll do the same thing here okay so now we should be okay pilot and run it and so again 20 and you can see like we're getting a bunch of bytes so one problem we have with this is that we're currently only updating the progress bar when a download completes so that's annoying the whole point of a progress bar or at least one of the main points is to give us hope for the future to tell us that our program is still working that it hasn't died you know don't kill it yet and and so this progress bar isn't doing that very well basically i don't know if i'm making any progress at all it just sits there and like gets stuck at 60 for a long time so the other problem in here is that we're currently treating all of our downloads the same right so like we think we're 60 of the way done we're nowhere close to 60 of the way done and what's going to happen once it finishes this download is it's just going to zoom to the end it's going to like sit at 60 for a long time and then all of a sudden we're going to be at 100 and it's going to be finished and we've all seen stuff like that like this download's gonna take one hour and then it ends up being ten minutes or the other way around right so let's see if we can tweak this make a few minor improvements and see if we can fix these issues or at least make things a little bit better okay so what i'm gonna do is the first thing i'm going to do is not update the bar in here what i want to do is to update the bar more often so we're going to update the bar every time we get new data okay so that should keep things updating while we wait even if we run into a really big download okay so we've already passed in our status info struct to the update bar function made sure we took care of that and we already up here in update bar we're already printing out the number of bytes now i actually don't like how how many it's it's showing in there so let's change this to mb and i'm going to just divide this by a million okay so now it's just going to show the number of megabytes that seems a little nicer to me anyway the whole point is that when i print out the bar at this point now i'm printing out the number of bytes so far a number of megabytes so far and so now anytime we get new data and this gets updated let's update this so what i want to do here is down in got data we got new data what i'd like to do is to update the bar so i'd like to call update status bar here and pass in some percent done value right that's what we do we pass in a percent done the problem is i have no idea how many bytes to expect and also while i'm bemoaning the fact that i don't know how many bytes to expect let's also add my status that's going to get passed in so now i can solve this in a few different ways i could do a head-only request for each url and get the download sizes and that might work web servers will often send you content length in the http headers occasionally though that information may not be available in some cases so even if it is available this is going to slow me down i'm going to make a bunch of extra connections i'm going to do extra work just so i know how much i'm downloading so you could do that you could totally do that and maybe if you're interested we could do that in a future video but today i'm not going to do that instead i'm just going to make some guesses maybe educated guesses maybe not and we'll just update those guesses as we go along okay so i can tell you up front it's not going to be perfect our predictions are going to be wildly inaccurate because all we have to go on is what we've seen in the past but let's start by adding a few things to our status struct and i'll come down here and fix this in a bit so the first thing i want to do is come down here and we're going to add a total expected member okay so this is going to tell us how many bytes we think we're getting and let's also add a double in here this is going to be a prediction it's going to be the expected bytes per url that i expect so for every download that i get there's a certain number of bytes that i expect to get and that's this is going to be a prediction here and then let's also make another one which is going to give me my current bytes this is going to be like the the number of bytes in the current download that's going to be important to keep track of and then also because we're we're we gotta we're trying to figure out the status because we're trying to figure out how far along how far we've come we're also going to need a url so far variable okay so that's going to keep track of how many of our downloads we've done so far and let's add one more while we're at it and keep track of our number of urls so this is let's call this total urls okay so now keep in mind there are a lot of different ways i could do this some might be more accurate than this one so if you think you have an improvement by all means make sure to mention it down in the comments i'd love to see what you come up with this is just what i came up with in a hurry now we also need to do some prediction okay so especially we're predicting how big future downloads are going to be there are a lot of different ways to do prediction today i'm just going to use a simple exponentially weighted moving average not because it's the most accurate predictor out there but because it's simple i don't want to write a lot of code and it's fast but mostly because i don't want to write a lot of code okay so for this to work let's first we need a weight anyone that's familiar with exponentially weighted moving averages know that you need a weight i call this predict i need to spell predict weight we'll set that to be 0.4 sometimes you may have seen this called alpha okay so it's your alpha value anyway it's the weight it's basically how much we're going to predict based on the last thing the the most recent thing we just saw okay so now let's make our function it's going to return a double and we're going to predict the next value based on two things and that's gonna you know the first thing we're gonna predict based on is the last prediction and we're also going to look at the actual number of bytes that we downloaded okay so we're going to we're going to get what we predicted was going to happen what actually happened and we're going to combine these using our weight so really all we're going to do is return and what we're going to return is the the last prediction and i'm going to multiply that by 1 minus our predict weight and then we're going to add to that we're gonna add our actual so the thing that we just saw multiplied by our predict weight okay so what this is gonna do is it's basically going to just take these two things and wait one a certain way and the other just the rest so i'll let you play around with the math a bit but you'll notice that basically if last prediction and actual are the same then the prediction's not going to change right it doesn't matter what the weights are and if i make the weight bigger let's say i'm all the way up to one then we're going to predict more based on the last measurement or the new data that we just received and if we make it lower then we're going to predict more based on our older predictions basically what we've predicted in the past and so that's how this predictor is going to work very simple nothing fancy you could definitely get fancier with this okay so now let's jump down into our got data function and see how we could use it now here we need to be a little more careful about how we do things the first thing i'm going to do is i need to update the current bytes okay so already you're updating the number of total bytes so let's come down and add this and let's set current bytes let's also add bytes to that so then we need to make a prediction once we've added we've increased the number of bytes and you know current bytes and total bytes now we need to make a prediction of how many we have left or how much how much work we have left and i'm going to break this down into pieces so that it's hopefully not too confusing okay so the first thing i'm going to do is let's create a new temporary variable called urls left like i said i could probably put this all on one line but i'm trying to make this as intuitive as i can so what we're going to do here is we're going to take our total urls minus our urls so far okay so this is pretty obvious but i just want to you know keep it conceptually straightforward and then next i want to estimate the size of the current download okay so let's make another one we're going to estimate the current download and i'm going to start out by just setting that equal to this expected bytes per url so this is our our global like our it's not global this is our prediction and our status information of what we think the average number of bytes per url is okay now of course it could be wrong so let's come in here and say what happens if our number of current bytes is actually greater than our expected bytes per url if that's the case then we know our prediction's wrong so for now let's just say let's estimate our current to be something else so maybe we can say it's current bytes and let's just let's be pessimistic here and say we got a bit left to go we we could assume we're almost there but i'm gonna say we're like three quarters of the way done okay so this means if we ever are past we're in uncharted territory we we've got a big download we're gonna be a little pessimistic and assume that it's got a ways to go now based on this estimate i want to guess what the next prediction is going to be okay so we'll use our predictor here and let's create let's say guess next prediction here and we're going to use our predict next function and we're just going to pass in our status and let's pass in our expected bytes per url okay so that's basically our old prediction and then let's pass in our estimated current okay so what we think we've got ahead of us again this is just a guess and this is the prediction that we're going to use to forecast the rest of our urls right because we're trying to update this this global progress bar and so now that we have our our sort of our next guest based prediction here now let's try to estimate the total bytes for all the downloads okay so this is really what we've been getting at all along but i need a spell estimated total okay this is going to be something like well let's let's start with our total bytes we know how many we've actually downloaded total so far right and then we need to add what we think we have left in the current download so that's going to be estimate current right and we're going to subtract off the current bytes from the current download some of those total bytes are part of the current download we have the estimated size of our current download so this is how much we have left in the current one and then what we're going to do is come in here and say urls left minus one so basically how many after this one we have times guess next prediction okay so this is this is an updated estimate of how long we think our future urls are going to take based on our new prediction that we just made okay so i know this is kind of a gnarly line of code but hopefully the math is pretty straightforward okay now once we have the estimated total now we just come in here and get our percent done i think i yeah no underscore down below and we're gonna take our total bytes multiply it by a hundred and divide it by our estimated total so now it's really simple we're just coming up with the percent and then we're going to pass that into our updated bar function okay so now the last thing we need to do to make this actually work is we're going to jump down back down into main and we need to update a few things one we need to come in here and set urls so far to be zero so we're gonna initialize that our total urls are going to be set to num urls that's how many urls we need to download and then we need to start with an initial prediction now for this i could pick whatever i wanted let's be a little bit pessimistic and i'm going to set let's do 100 megs okay whatever i pick if i pick something too small then my progress bar is going to grow really fast and then slow way down if i start too big then it's going to be really pessimistic until it gets a couple of downloads under its belt and then it's going to start to calibrate itself and get a little bit better so let's start on the big side and then we'll just let it adjust as it goes and see what happens but of course as always feel free to tune this as needed for your individuals needs right okay so now let's come down into our for loop and see if we can make some changes the first is before each download i need to set current bytes reset it back to zero and then of course we don't need to update our bar down here because we're doing it every step of the way every time we get some data but we do need to update our number of urls so far after each of our downloads and let's also update our prediction each time through i was making some temporary predictions but we now need to basically once we're done and we know how many bytes we actually got let's use our predictor to predict what the what things are going to be like from now on now that we have actual information and so let's start with our old prediction and our and the current bytes basically how many we got from the current download okay so this is gonna update our prediction so this should work assuming i haven't made any mistakes of course uh there's always possibilities so we never know how this is actually gonna go but let's try to run it so here you notice that it is updating okay you notice it's still working we're moving along it started out kind of slow because it was very pessimistic but now things are moving a lot faster you know it's it's adjusting itself at this point you know 35 megabytes in we're definitely on our big download so you notice how it went forward and then it came back a little because it's like whoa this one's really big and so it's keeps adjusting and as it goes it's probably going to keep adjusting back a little bit although it's interesting it's making forward progress and also discovering that it's got a really big file on its hands all at the same time and this is something that you've come to expect from progress bars in your life and hopefully at this point you're starting to understand why i mean obviously people want their progress bars to be as accurate as possible but as a developer you're up against two key truths the first is you never know how long things are going to take to complete in this case the uncertainty comes from the unknown download size we just don't know how big our downloads are and even if we knew how big our downloads were going to be the server could slow down due to a lot of traffic or traffic on my local network or on the internet as a whole could increase or my computer could start rendering a video or something that takes all my processor time and that could slow things down whatever the reason the point is that there are a lot of reasons that i might think that i'm almost done and then things could slow way down and they could speed back up again and so getting this right is actually really hard in general now the second truth is that we can rarely afford to spend a lot of time on making great progress bars the point of a progress bar in most real software is to give you some comfort that the program is still working i mentioned that before we wouldn't complain of course if our progress bar was more accurate but it's probably not going to make the difference between whether or not i buy your software or whether i don't and getting really fancy with improving prediction is probably also going to slow things down it's going to take up processor speed it may take up network bandwidth and so for most of us in most of our applications the progress bar becomes an exercise in good enough it needs to keep moving and let's try not to make it too bad but it's rarely worth going to great lengths to make it perfect so i hope that helps you put a progress bar in your next program and i also hope in the future from now on whenever you see a progress bar that's not all that accurate hopefully you'll give it a knowing look and be like that makes sense i get you keep working little program you're going to make it thanks for being here i hope you enjoyed it like the video subscribe if you don't want to miss the next one and until then i'll see you later
Info
Channel: Jacob Sorber
Views: 35,026
Rating: undefined out of 5
Keywords: progress bar example c, progress bar exemple c, progress bar c, progress bars, progress bar tutorial, progress bar in terminal, terminal progress bar, terminal progress bar in c, c programming example, c programming tutorial, stdout progress bar, why are progress bars bad, why progress bars are always wrong, Why progress bars are wrong
Id: t_vM_8TLjFE
Channel Id: undefined
Length: 35min 44sec (2144 seconds)
Published: Tue Jun 01 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.