Generate Event frame if tag value in bad state for more than 15 min.

I need to generate event frame if tag value in bad state for more than 15 min. Input tag is coming so frequently in data archive. I need to calculate the exact start time & end time in event frame.

I have done calculation based on below function. But ,It is impacting on system performance. Is there alternative ways to do it ?

1) TagAvg('Input','*','*-1m') -- Store in 1 Min Avg PI tag

2) if BadVal(TagAvg('1 Min Avg PI tag','*','*-15m')) then 1 else 0 -- Store in Trigger PI tag

3) Event frame based on Trigger PI tag.

All Above analysis are running on periodically with every 1 min duration.
Input Data.jpg