Okay, i removed unused variable, added 3 writeln()s, a freeze, and then tested it with a loop. Pay attention to the distance between the first two and the second two numbers (but not their values)
Compiled successfully in 16 ms.
62//called right before the for..to..do
62//right after (searching is done) ( num 2- num1 = time to do FindColorsFastTolerance
109//after findcolorstolerance (num 3 - num2 = time to do findcolorstolerance)
------------------
156
172
203
------------------
250
265
281
------------------
328
343
390
------------------
452
468
499
------------------
546
562
608
------------------
655
671
702
------------------
749
764
811
------------------
858
874
905
------------------
952
967
983
------------------
1045
1045
1092
------------------
1123
1139
1170
------------------
1217
1232
1248
------------------
1295
1310
1357
------------------
1404
1420
1451
------------------
1498
1513
1560
------------------
1607
1622
1654
------------------
1700
1716
1732
------------------
1794
1810
1841
------------------
1888
1903
1934
------------------
1981
1997
2028
------------------
2075
2090
2122
------------------
2168
2184
2215
------------------
2278
2293
2324
------------------
2356
2371
2418
------------------
2496
2512
2543
------------------
2590
2605
2636
------------------
2683
2699
2746
------------------
2792
2808
2839
------------------
2886
2902
2917
------------------
2964
2980
3011
------------------
3058
3073
3104
------------------
3151
3167
3214
------------------
3245
3260
3307
------------------
3354
3354
3385
------------------
3448
3448
3494
------------------
3526
3541
3588
------------------
3635
3650
3682
------------------
3744
3760
3791
------------------
3853
3869
3900
------------------
3962
3978
4009
------------------
4056
4072
4103
------------------
4150
4165
4212
------------------
4259
4274
4306
------------------
4352
4368
4399
------------------
4446
4462
4508
------------------
4555
4555
4586
------------------
4633
4649
4696
------------------
4727
4742
4789
------------------
4836
4852
4883
------------------
4930
4945
4992
------------------
5039
5054
5086
------------------
5132
5148
5195
------------------
5242
5257
5288
------------------
5335
5351
5382
------------------
5429
5444
5491
------------------
5538
5538
5569
------------------
5616
5632
5647
------------------
5694
5710
5756
------------------
5803
5819
5850
------------------
5897
5912
5959
------------------
6022
6037
6068
------------------
6115
6131
6178
------------------
6224
6240
6271
------------------
6318
6334
6349
------------------
6396
6412
6443
------------------
6474
6490
6536
------------------
6599
6599
6646
------------------
6677
6692
6739
------------------
6786
6802
6833
------------------
6880
6895
6942
------------------
6989
7004
7036
------------------
7082
7098
7145
------------------
7192
7207
7238
------------------
7285
7301
7332
------------------
7379
7394
7426
------------------
7457
7488
7519
------------------
7566
7582
7628
------------------
7675
7691
7722
------------------
7769
7784
7800
------------------
7847
7862
7894
------------------
7925
7956
7987
------------------
Successfully executed.
It's usually faster. And not even in a plugin yet.
And this is what I ran to test it:
program new;
procedure FindColorsFastTolerance(var TPA:TPointArray; color, x1,y1,x2,y2,tol:integer);
var searches,i,boobs:integer;
tmpTPA:TPointArray;
begin
//GetClientDimensions(clinetH,ClientW);
searches := (x2-x1) /2; //number of searches to perform while skipping a pixel (get search area W, divides by 2)
boobs := x1; //this is the xs value, and the x1 of the search each time after
freeze;
writeln(tostr(gettimerunning))
for i := 1 {0?} to searches do
begin
findcolorsTolerance(tmpTPA,color,boobs,y1,boobs,y2,tol);
appendTPA(TPA,tmpTPA); //adds any colors found to the result
IncEx(boobs,2);
end;
unfreeze;
writeln(tostr(gettimerunning))
end;
var TPA:TPointArray;
begin
repeat
FindColorsFastTolerance(TPA,0,0,0,500,500,0)
FindColorsTolerance(TPA,0,0,0,500,500,0)
writeln(tostr(gettimerunning))
writeln('------------------');
until(false);
end.