mathtime-estimation

How can I calculate the copy overhead per file?


If given a mapping of file sizes to their respective transfer times, how can I approximate the constant factor that each file will have as overhead?

E.g.

File size          Transfer time
--------------------------------
     1 kB                   2 ms
  1000 kB                1001 ms
--------------------------------

From this table I can see that each file has an overhead of 1 ms and each kB takes another ms. But how do I do this mathematically?

I need to calculate this in C++ as a moving average for an estimation of remaining copy time and would be grateful for some ideas (just math or pseudocode is ok.)


Solution

  • As you said, there are two variables:

    So, for the two files:

    1. 2ms = T + 1A
    2. 1001ms = T + 1000A

    Subtract 1) from 2):

    (1001ms - 2ms) = (T - T) + (1000A - A)
    999ms = 0 + 999A
    999ms = 999A
    A = 1ms
    

    Substitute for A in 1):

    2ms = T + 1
    1ms = T
    

    Simple simultaneous equations!