'At a time' or 'in a time'
At
In your example “at a time” would refer to a particular moment or an instant in which we want the number of insects.
“In a time” would refer to a duration of time at the end of which we are calculating the number of insects.
I think you mean to use the former version, therefore “at a time” is what is correct according to me.