Thanks for all the suggestions.
The pipe diameter is 50mm at the outlet and the inlet, so I assume the farthest distance the object is away from the proximity sensor would be no more than 50mm.
The diameter of the metallic core plastic ball is 15mm. The metallic core is non-ferromagnetic.
When the pump starts, the containing chamber will open the gate, and release all the plastic balls, then it will close the gate at the outlet and open the inlet gate, after the proximity sensors has detected all the plastic balls had left the chamber. The circuit will record the time the first plastic ball and the last one left the chamber, likewise for the returning plastic balls, before closing the gate at the inlet, and shutting down the pump, after the last plastic ball return to the chamber.
As the pipe diameter is 50mm, there would be more than 1 plastic balls will passing by the proximity sensor at the same time.
Here is a brief sketch, maybe it would be easier to visualize.