Shortcut to calculate time for data transfer?

Does anyone here have a shortcut to calculate data transfer time given specified data rate? Extra points if it can somehow detect the current bandwidth to base the calculation on. If no-one has such a shortcut already I’ll work one out and post here (although I can’t see a way to get the current network data rate).

Data rates can and usually do differ between upload and download. First you need to identify the direction of transfer.

After that you an either time a known file size upload or download accordingly to get *a* transfer rate.

Once you have the bps, just divide the file size by that to get number of seconds. Adjust midnight be that many seconds to convert to minutes and seconds.

However, note that transfer rates vary by host location being connected to. Testing a rate against one host and then using it on another is can vary substantially for accuracy. Also rates vary over time. This is particularly true if you are not using a dedicated sole connection (many businesses use this sort of connection for example), but rather a shared circuit connection such as a broadband (note wifi compounds this) or cellular connection where the connections circuit is shared by a variable number of users with varying data demands.

The best level of accuracy on throughput and time is calculated in parallel with the upload/download operation. That’s not something Shortcuts can do. Basically your mileage is likely to vary quite a bit in terms of accuracy.

1 Like

Thanks for the great reply. I’m familiar with most of what you say (although “midnight” typo?), but I should have been clearer that I’m not wanting exhaustive precision but to guesstimate how long a large transfer may take over my current connection, usually my home broadband (for when I’m transferring large media files for work).

Anyway, here’s a quick draft of the kind of shortcut I mean (but beware I’ve not checked the calculation).

If there was a way to test the current upload/download speeds it could feed that figure into the calculation, possibly via an app like Speedtest from Ookla or a speedtest website, but hard-coded figures are adequate.

Not a typo. Midnight is 00:00:00. If you adjust that in seconds, it’ll give you hh:mm:ss format for duration instead of just seconds.

  1. Get the current time.
  2. Upload a test file of known small-ish size to your final destination.
  3. Get current time.
  4. Calculate the time difference.
  5. Calculate the upload transfer rate.
  6. Get current time.
  7. Download the test file.
  8. Get the current time.
  9. Calculate the time difference.
  10. Calculate the download transfer rate.
  11. Remove the Test file from the destination.
  12. Get size of actual file to be uploaded/downloaded and retained.
  13. Calculate upload/download duration for actual file based on earlier rates.

Particular routers and firewalls may have options to maintain a throughput log, so if you were using something like pfSense, you might have some alternative options that you could base on historical data speeds if you could find a way to periodically generate a log and then aggregate the details to give you an idea of an estimated speed/data rate.

1 Like

Thanks again. Your suggestion is an engineer’s solution which my layman’s problem doesn’t really warrant so I’ll manage without testing the actual speed. A rough idea is all I’m after.

I see what you mean now about midnight. I might try that.

Okay. For a ballpark estimate approach does this fit for you?

It just calculates duration based on file size of a user selected file and a user specified data rate in bps. I used the average UK home broadband download speed as a default rate.

  • Anything below 1 second will be set to 1 second.
  • Estimates shown only as whole numbers of seconds.
1 Like

I kinda see where you’re going with that but I think the draft I posted is closer to what I need, even if the way I’ve done it is a bit clumsy. Here’s my updated version, which seems to provide believable estimates and is probably good enough for my purposes.

(I should add that I’d welcome comments on how I’ve built that shortcut; it’s all about learning.)

On the subject of formatting the time, there’s a nice parameter in the Calendar action for Total Time which shows the duration in everyday language.

@sylumer beat me to it again. :slight_smile:

You can’t calculate data transfer time. You can only guesstimate it.:slight_smile:

Please be careful not to alienate people here. I’m a layman, not a programmer, and the fact I didn’t use the right terminology isn’t a reason to laugh. My impression of this forum is that it was set up in line with the philosophy of Shortcuts to allow non-programmers to use automation, and professionals being snooty isn’t in that spirit.

Seriously, I’m sure there are plenty of geeky forums for you experts to have a chuckle at the newbies.

If that was directed at me all I can say is my “contribution” was a joke we can all relate to: We’ve all been victims of progress meters and estimations that were anything but believable.