Require Formula - If Even Possible
I'm writing a system tool written in Java which essentially, starts a task at t0 and completes in N secs. Because I anticipate this tool to run on different machines, the time to perform a task will vary.
So, before this tool starts, it needs to do a one-off calibration so that it can accurately predict how long tasks will take to complete ("accurate" as in 1 to 3 secs is fine).
Basically I have measurements for x and y, which completes in N seconds...
x y N Seconds ------------------------------------------------------------ 1.0 15 5.54 1.5 15 3.64 2.0 15 2.73 1.0 35 12.7 1.5 35 8.44 2.0 35 6.23 1.0 55 19.9 1.5 55 13.8 2.0 开发者_如何学JAVA 55 10.3
Given the measurements above, can I derive a magic formula which says, "if a task is to complete in 15 seconds, then x has to be "blah" and y is "blah".
Obviously math isn't my strong point, is a formula even possible?
Thanks!
From playing around with the data in the question, it looks like this function is a fairly good approximation.
z = y / (x * 2.67)
For example, for x = 1.5, and y = 15, it gives 3.74, and for x = 1.0 and y = 55, it gives 20.6.
You have two free parameters, so if you want say, z = 15, then you can just substitute and get an estimate for y or x. Without knowing one, you can't really know the other.
15 = y / (x * 2.67)
15 / (x * 2.67) = y
y = 5.83 / x
x = 5.83 / y
If you need just the values in the table, simply use that table. If you need more, you have to use some function interpolation method to get the formula, for exapmple polynomial interpolation
if a task is to complete in 15 seconds, then x has to be "blah" and y is "blah"
There can possibly infinte solutions for the above. But it would make senses to find a x, given y and N.
Basically you want to find correlation between x,y and N. There are many algorithms to determine linear correlation like Linear regression.
Unless you are running in fundamentally different machines like one machine is a client WInXP and another a Linux Box, I dont think you need to dwell this deep, because chances are other small things can overcome the timings(for e.g. other processes running on system)
精彩评论