There is no apparent parameter for this.
The Halakha is basically as soon as one feels the onset of any sort of bowel movement then they should try their best to relieve themselves.
The only exception would obviously be at the risk to human life or the like.
The concept is based on keeping one's body as healthy as possible in order to have a longer and healthier life to perform many more miswoth.
"Since maintaining a healthy and sound body is among the ways of G-d - for one cannot understand or have any knowledge of the Creator, if he is ill - therefore, he must avoid that which harms the body and accustom himself to that which is healthful and helps the body become stronger.
They are as follows: a person should never eat unless he is hungry, nor drink unless thirsty. He should never put off relieving himself, even for an instant. Rather, whenever he [feels the] need to urinate or move his bowels, he should do so immediately. - Rambam Hilkhoth De'oth 4:1
And goes further to explain the depths of this concept:
Similarly, it is forbidden for a person to delay relieving himself at all, whether through defecation or urination. Anyone who delays relieving himself is considered among those who make their souls detestable in addition to the severe illnesses he brings upon himself and becoming liable for his life. Instead, it is appropriate for a person to train himself [to eliminate] at specific times so that he will not have to separate himself in the presence of others and not have to make his soul detestable.
Whoever is careful concerning these matters brings an additional measure of holiness and purity to his soul and purges his soul for the sake of the Holy One, blessed be He, as [Leviticus 11:44] states: "And you shall sanctify yourselves and you will be holy, for I am holy.- Rambam Hilkhoth Ma'akhaloth 'asuroth 17:31-32, also see Mahadura Basra 3:1 S"A
I only know of one place an example is given where the concept of relieving oneself is specifically mentioned in relation to performing a commandment, and that is in relation to tefilah
"...One who must relieve himself should not pray. Whenever anyone who must relieve himself prays, his prayer is an abomination and he must pray again after he relieves himself.
If a person can restrain himself for the length of time that it takes to walk a parsah, his prayer is considered prayer.
Nevertheless, a priori, one should not pray until he has checked himself very well, checked his intestines, rid himself of phlegm and mucus and any [other] bothersome thing. [Only] afterwards should he pray... When urine flows on a person's legs during Shemoneh Esreh, he should wait until the flow ceases, and return to the place at which he stopped. If he waited the time necessary to complete his Shemoneh Esreh, he should return to the beginning.
Similarly, one who urinates should wait the length of time it takes to walk four cubits, and then pray. After one has prayed, he should wait this length of time before urinating, in order to make a distinction following the words of prayer. - Rambam Hilkhoth Tefilah 4:10,13-14