25
5
Is there on Linux a program that can calculate how much data a program would produce?
For example, if I would like to take backup of my MySQL database I would usually do
mysqldump > dumpfile.sql
Instead I would like to redirect to /dev/null
but calculate how much disk-space would have been used, like
mysqldump | fancy_space_calc_program
Output:
123456789 Bytes would have been used
Note, the MySQL backup is just an example. I'm very well aware of how I could estimate the size before-hand, so please no comments about that.
1I don't even think you can really make one; for specific cases yes, but not general usage, because how you can estimate if some app calls some server and downloads data from there - no chance you can estimate such things in foreign apps. So this would be per app - as you write that you already know for MYSQL - no explanation there, but other apps - per app, no general tool could do such prediction correctly. – Drako – 2017-05-29T13:43:46.813
1I hope you realize that any attempt to make the estimate would require to actually run the program and observe the output while it is send somewhere safe. This is going to be impossible if the program has some sort of irreversible effect on something else so you can ONLY run it once without unintended side-effects. The other problem is that if the program derives its output from a changing input the next run is going to create another (different size) output-file. Last but not least: diskspace <> (bytes of output). And various filesystems have different overheads for bookkeeping. – Tonny – 2017-05-29T18:52:41.420
1Yes, I'm well aware of that. It's still good enough for me. – fancyPants – 2017-05-29T19:55:51.230
@Drako You can have a general way of measuring the text output of a program. That does not need to be per app (see e.g. the accepted answer). Whether or not the text output will be reliably identical on subsequent runs is app-specific, but that does not prevent you from measuring the output in a general way. Presumably the OP and anyone else trying to measure output would only do so if the data was meaningful for any given application. – Jon Bentley – 2017-05-30T12:59:34.530
@JonBentley I never told you can not have it, read more carefully: "as I wrote general prediction is not going to be precise or even close :)" and now imagine that my app after running will check for updates of itself, of plugins, etc and will download x amount of data from i-net and store that on your hdd; how you are going to precisely measure in advance with general tool not knowing anything about my app, how much storage will be needed after running it? Still you can do your best guess with accepted answer and in many cases even be pretty precise. – Drako – 2017-05-30T14:53:07.717
@drako Yes you did, you wrote "I don't even think you can really make one - for specific cases yes, but not general usage". You can have one for general usage, and it will perform its job even for applications whose output varies. It's your job as the user to make sure you're using it on an application where the data you get will be meaningful. No reasonable person would use the tool on something which will output random data that it got from the internet - that's obvious. – Jon Bentley – 2017-05-30T18:49:39.467