This one shall be similar (in speed) to previous one, while new functionality (skipping two rooms) is added. If one would try to add checking last occurence of TOD or 2 Nine - to old one, the new one shall be much faster.
If your dataset is really big (say 10000 rows+) one can consider change the formula after first few rows.
Let's say that estimated max distance between two lines with COMPANY is X and let's assume it is 12 as in your sample data: 12 rows between rows 4 and 16.
So in some 12*1.5 (added-security factor) = 18 row after formula was first introduced, so in row 23, we change the formula from
as it is now,
and copy this one down. Will be blistering-quick :-P
Or to answer directly - how to check - just generate enough data and test each of them, comparying calculation time :-)