Calculate the max samples with ramp up - math

I got this math problem. I am trying to calculate the max amount of samples when the response time is zero. My test has 3 samples (HTTP Request). The total test wait time is 11 seconds. The test is run for 15 minutes and 25 seconds. The ramp up is 25 seconds, this means that for every second 2 users are created till we reach 50.
Normally you have to wait for the server to respond, but I am trying to calculate the max amount of samples (this means response time is zero.) How do i do this. I can't simply do ((15 * 60 + 25) / 11) * 50. Because of the ramp up.
Any ideas?
EDIT:
Maybe I should translate this problem into something generic and not specific to JMeter So consider this (maybe it will make sense to me aswel ;)).
50 people are walking laps around the park. Each lap takes exactly 11 seconds to run. We got 15 minutes and 25 seconds to walk as many as possible laps. We cannot start all at the sametime but we can start 2 every second (25seconds till we are all running). How many laps can we run?
What i end up doing was manually adding it all up...
Since it takes 25s to get up to full speed, only 2 people can walk for 900s and 2 people can walk for 901s and 2 people can walk for 902s all the way to total of 50 people..
Adding that number together should give me my number i think.
If I am doing something wrong or based on wrong conclusion I like to hear your opinion ;). Or if somebody can see a formula.
Thanks in advance

I have no idea about jmeter, but I do understand your question about people running round the park :-).
If you want an exact answer to that question which ignores partial laps round the park, you'll need to do (in C/java terminology) a for loop to work it out. This is because to ignore partial laps it's necessary to round down the number of possible laps, and there isn't a simple formula that's going to take the rounding down into account. Doing that in Excel, I calculate that 4012 complete laps are possible by the 50 people.
However, if you're happy to include partial laps, you just need to work out the total number of seconds available (taking account of the ramp up), then divide by the number of people starting each second, and finally divide by how many seconds it takes to run the lap. The total number of seconds available is an arithmetic progression.
To write down the formula that includes partial laps, some notation is needed:
T = Total number of seconds (i.e. 900, given that there are 15 minutes)
P = number of People (i.e. 50)
S = number of people who can start at the Same time (i.e. 2)
L = time in seconds for a Lap (i.e. 11)
Then the formula for the total number of laps, including partial laps is
Number of Laps = P * (2 * T - (P/S - 1)) / (2*L)
which in this case equals 4036.36.

Assume we're given:
T = total seconds = 925
W = walkers = 50
N = number of walkers that can start together = 2
S = stagger (seconds between starting groups) = 1
L = lap time = 11
G = number of starting groups = ceiling(W/N) = 25
Where all are positive, W and N are integers, and T >= S*(G-1) (i.e. all walkers have a chance to start). I am assuming the first group start walking at time 0, not S seconds later.
We can break up the time into the ramp period:
Ramp laps = summation(integer i, 0 <= i < G, N*S*(G-i-1)/L)
= N*S*G*(G-1)/(2*L)
and the steady state period (once all the walkers have started):
Steady state laps = W * (T - S*(G-1))/L
Adding these two together and simplifying a little, we get:
Laps = ( N*S*G*(G-1)/2 + W*(T-S*(G-1)) ) / L
This works out to be 4150 laps.
There is a closed form solution if you're only interested in full laps. If that's the case, just let me know.

Related

How to calculate steps needed for arrow to fill all given sectors of the clock?

the problem's data are:
Analog clock is dived into 512 even sections, arrow/handle starts its movement at 0° and each tick/step moves it by 4.01°. Arrow/Handle can move only clockwise. What minimum ticks/steps count is needed for arrow/handle to visit all sections of the clock.
I'm trying to write a formula to calculate the count but can't quite wrap my head around it.
Is it possible to do it? If yes, how can I do it?
This site is for programmers, isn't it?
So we can hire our silicon friend to work for us ;)
Full circle is 360*60*60*4=5184000 units (unit is a quarter of angular second)
One step is 4*(4*3600+36) = 57744 units
One section is 4*360*3600/512 = 10125 units (we use quarters to make this value integer)
cntr = set()
an = 0
step = 57744
div = 10125
mod = 5184000
c = 0
while len(cntr) < 512:
sec = (an % mod) // div
cntr.add(sec)
an += step
c += 1
print(c)
>>804
unfortunately I can`t fully answer your question but the following may help:
Dividing the 512 Sections into degree gives you 1,4222° each.
Each round you cover 90 different section when starting between 0°-3.11° and 89° when starting between 3.12°-4.00°
For starting the rounds this gives you a change in starting degree of 0.9° every round except after the fourth, where it is only 0.89°(within the possible range of 0°-4° so all calculated mod 4).
So you have 0.9°->1.8°->2.7°->3.6°->0.49->1.39°...0.08°...
I hope this helps you devloping an algorithm

I'm stuck with a logistics formula I need for a simple game

i'm a bit stuck with a calculation and I hope someone can help me to solve this.
I want to calculate an x amounts of containes that needs to be delivered within a certain period of days, taking in account that a truck with one container takes an x amount of days to deliver one container and return to reload again.
I want to calculate / create a formula how many trucks I need to deliver all the containers within the maximum amount of days that are given.
So I have the following variables:
Total amount of truck containers
Maximum window of days to deliver all the containers
Days that one truck needs to make one round
For example:
5 containers
21 day to deliver all the containers
7 days a truck needs to make one round
I use the following calculation:
5 (containers) / 23 (days to deliver) * 7 (days to make one round) = 1,52 trucks needed
30 (containers) / 30 (days to deliver) * 7 (days to make one round) = 7 trucks needed (but here I miss one truck, because I need 8 trucks to deliver 30 containers.
I know I'm missing something, but maths are not my strongest field of expertise and can't seem to find what I miss here.
I hope someone can point me in the right direction.
It's not quite that simple. If one truck delivers one container at a time, it takes a truck D days to deliver. Then it takes R days to return to the warehouse for the next container.
So the first delivery takes D time, and each subsequent delivery takes R+D time.
Days for 1 truck to make n deliveries is then D + (n-1)(R+D). Simplifying that's: days = n(R+D)-R. So the number of deliveries one truck can make in Y days is n = (Y+R)/(R+D).
Now you've got the number of deliveries one truck can make (round down).
So in Y days, if one truck can make n deliveries, you have m = N/n, where m = # trucks, N = total # deliveries, and n = deliveries by one truck. In this case round up.
To check the math, you said 5 containers, 21 days, 7 day round trip which I'll convert to 4+3.
Y=21, D=4, R=3, N=5: n = (21 + 3)/(4+3) = 24 / 7 = 3.x, round down to 3. Then m = 5/3 = 1.x, round up to 2.
Thinking that out logically, 2 trucks deliver 2 containers in 7 days. 2 trucks deliver an additional two containers in 7 days. That leaves 7 days remaining, one package remaining, one truck delivers it, one truck sits idle that last cycle. So the math checks out.

How to detect the start and end of pieces in a stitched video?

I am trying to figure out how to process a special video for an application that I trying to build. After days of research, I cannot figure out how to achieve what I am trying to build:
The user passes in a video that is X minutes long. The video was produced was stitching together multiple videos of variable length(with a maximum length per video of K seconds, say 60). The purpose of the app is to detect when each video starts and ends within the larger video of X minutes.
For example, the user passes in a video that is 25(this is X) minutes long. We know that a single video cannot be more than 10(this is K) minutes. So the maximum number of videos that the user could have stitched together to produce the input video is 3 videos(Two ten minute videos and one 5 minute video). But this is not always case, another possible combination is(Five 5 minute videos, etc).
I've been researching this for days and cannot come up with any way mathematically to solve this(very possibly due to my limited math knowledge). Is it possible to solve this problem(where each of the stitched videos begin and end)?
Thank you for any help! It's sincerely appreciated.
If you want to use only integer units (munutes, seconds), then calculate two values
R = X % K - integer modulo 7 % 3 = 1, residue
M = X / K -integer division 7 / 3 = 2
If residue R is zero, then overall number of video segments is M, else M + 1.
Start time of i-th video segment is Ts[i] = i * K
End time of i-th video segment is Te[i] = (i + 1) * K for all but the last segment Te[last] = X
I hope it is very basic math.

Simple Steering Behaviour: Explain This Line

I am reading the book Programming Game AI by Example, and he gives code for
a steering behaviour which causes the entity to decelerate so that it arrives
gracefully at a target. After calculating dist, the distance from target to
source he then (essentially) does this
double speed = dist/deceleration;
I just cannot understand where this comes from however, am I just missing something
really obvious? It is not listed as a known error in the book so I am guessing it
is correct.
If there was some physical truth to this, the units would have match up on either side.
From what I understand, this is akin to Zeno's paradoxes where you are trying to reach something, but you never get there because you always only travel one nth of the remaining distance.
Suppose
the simulation proceeds at intervals of one second at a time.
deceleration = 5
distance = 1000 meters
With these initial conditions, speed will be set to 200 meters per second. Because the simulation proceeds at intervals of one second, we will travel exactly 200 meters (i.e. one fifth of the remaining distance), and end up at a distance of 800 meters from the target. The new speed is determined to be: 160 meters per second
Here is what happens in the first 30 seconds:
The last 30 seconds:
The last 10 seconds:
Observations
Within the first 30 seconds, we travel roughly 998 meters
Within the first 50 seconds, we cover 999.985 meters
Within the last 10 seconds, we cover only ~1.2cm
As you can see, you get almost there very quickly, but it takes a long time to get close.
Plots by WolframAlpha
Maybe there is something missing in your calculation. For a constant accelaration (or decelleration), and ignoring initial condictions, the speed is
v = a * t
and the distance is
d = a * t^2 / 2
If you eliminate t in both equations you get
v = a * sqrt(2 * d / a)

Calculating duration when you have hours, minutes, seconds, and milliseconds

I am writing a program in Fortran and I need a way of calculating the duration of the program down to milliseconds. I have been using the function "date_and_time", which leaves me with an array containing the system's time in hours, minutes, seconds, and milliseconds.
I believe that I can call this function at the start of my program to store the current time, then call the function again at the end of my program to store the latest time. But after that, how would I computer the duration? I tried just subtracting the values, but the milliseconds reset when one second passes, just like the seconds reset when one minute passes. How would be best way to approach this be?
Here is the program:
PROGRAM TEST_TIME_AND_DATE
INTEGER I
REAL J
INTEGER TIME_A(8), TIME_B(8)
CALL DATE_AND_TIME(VALUES=TIME_A)
PRINT '(8I5))', TIME_A
DO I = 0, 400000000
J = I * I - J
END DO
CALL DATE_AND_TIME(VALUES=TIME_B)
print '(8I5))', TIME_B
END PROGRAM TEST_TIME_AND_DATE
And here is the result:
2011 6 11 -300 9 14 49 304
2011 6 11 -300 9 14 50 688
I'm not sure what to do here, thanks.
If you want elapsed clock time, it would be simpler to use the intrinsic procedure system_clock since it provides a single time-value output. (There are additional arguments to provide information about the procedure, which is why it is a procedure instead of a function.) See, for example, http://gcc.gnu.org/onlinedocs/gfortran/SYSTEM_005fCLOCK.html. If you want to time the CPU usage, then use cpu_time. For either, two calls, at the start and end of the program, then a simple difference. You can use the COUNT_RATE argument to convert to integer count of time into seconds.
You can subtract the numbers, then convert everything into milliseconds and sum up the ms, sec in ms, min in ms, hrs in ms, ...
In your case this would be
0 + 0 + 0 + 0 + 0 + 1*1000 + 384 = 1384 [ms]
This approach works fine also with overflows since a positive number in a left-more column outweights negative numbers if they are all converted to the same basis. E.g. 0:58.000 to 1:02.200 yields
1 * 60000 + (-56) * 1000 + 200 = 4200
Please note that this does work up to days but not with months since they do not share a common length.
You could calculate the offset from some starting time (Jan 1, 1970 for UNIX) in seconds or milliseconds. The difference in those numbers is your elapsed time.
(2011 - 1970) * (number of seconds in a year) +
(month of the year - 1) * (number of seconds in a month) +
(day of the month - 1) * (number of seconds in a day) +
( ... )

Resources