No. There needs to be a class that holds the item's value and start time so that the start time is with the item.
Type: Posts; User: Norm
No. There needs to be a class that holds the item's value and start time so that the start time is with the item.
If the start time is NOT saved with the item, then there will only be one value in the program. There needs to be a starttime saved for EACH ITEM.
I'm talking about this statement:
startTime = System.currentTimeMillis(); // ***** GET TIME *****
I don't see any use of the Timer class in the posted code.
The start and stop times are not associated with the items. If two items are added before one is removed, the start time for the first item is lost. When the first item added is removed, its start...
How are the values of those variables set? If they are not given values, their value would be 0.
I'm not sure how that works. The time between events would be the difference between the time when an item is added and the time when it is removed.
The code should NOT use hardcoded magic numbers. Values in variables should be used to control loops.
I have compiled and executed it. I changed one of the 10 to a 2 for quicker testing and the...
Then you do not understand the problem.
Questions on the code:
Why the hardcoded 10 in two places vs a single parameter to control the number of loops the code takes?
Why does the Watcher...
I really don't have another suggestion. I've said the same thing now several times.
If there is no test scheme to validate the results. Then will any answer work?
It seems like a waste of time...
Can there be more than one item in the buffer? If so, the times of the events should be kept with the item.
What are the ins and outs used for? Would ins == outs at the end of the run? To make...
There are printlns for when the item is added and when it is removed. Do they define the times of the two events you are interested in? If so, at the add, save the time in the item object. At the...
SorrY I don't know what those counters are used for.
I was talking about recording the clock time when an item is inserted and subtracting it from the clock time when the item is removed.
When an item is inserted, record the time in the object. When the item's object is removed, compute the duration.
Save the item with the saved duration in a list somewhere.
How about a class whose objects will hold the time of its insertion?
The System class has a method that returns the PC's current time in a long.
How will the code associate the time of insertion with the item that was inserted?
Which part is the problem:
Getting the time of insertion
getting the time of removal
computing the difference
summing the times
computing the average