Same Script filter is Extremly fast and Extremly slow with a small change. Why

My script when used in filter, returns extremly slowly for the results I
want, however, if I just make the script return any doc that doesn't match
my criteria.. i,e. just by FLIPPING the RETURN statement , query returns
quite fast.

same behavior is noticed every single time , even when .. out of 6k docs I
query on, the fast case matches 5.5k docs and the slow case matches, well
,the rest.. i.e. 0.5k
Same behavior is noticed no matter how I change my input parameters... how
I manipulate the script (without changing the bussiness logic)
._________________________.

I am running on single node.. with Shards = 1, Replicas =0
Example document looks like this..

{
"data": {
"id": "123",
"timeseries": [{
date: "2004-08-16T00:00:00",
value: 3 },
{
date: "2004-12-14T00:00:00",
value: 2
}]
}
}

i.e. each document has an array "timeseries" which stores historical data.
I have a mvel script just comparing historical data..

as_of_val=0;
foreach(val:_source.data.timeseries)
{
if(val.date < start_date)
{
as_of_val = val.value;
}
}

ret = false;
if( as_of_val == rating1 ){
ret=true;
}

return ret;

============================

Now above script is the logic I require... and it takes like 80 sec to
return the filtered docs.. ( I only fetch 200 docs tho).. no matter how I
change my input parameters.. (consequently regardless of number of docs
matched)..

Now.. if I just change return statement to "return !ret" ... the query
returns in 1 sec! no matter how I change my input parameters..
(consequently regardless of number of docs matched)..

Not just that...even if I switch .. " ret = false; ret = true;"
statements.. are whatever... when the script essentially does what my above
script does.. it takes constantly 80sec... but when it essentially does
the exact opposite.. it takes 1sec..

I tried putting my script in "not:{} " ... even then.. its same behavior...

Can anyone explain this behavior pls?