Closed adishavit closed 7 years ago
The performance difference in Chrome latest stable is 3%. The JiT compiler has gotten very good at optimizing math functions and storing shadow variables!
Used jsPerf for this simplified formula, compared to current DeltaE implementation:
return(x2.L - x1.L) * (x2.L - x1.L) + (x2.A - x1.A) * (x2.A - x1.A) + (x2.B - x1.B) * (x2.B - x1.B);
The GitHub Page for this repo has a demo that actually has a speedier version running (see code sample at bottom for notes):
Since all you are doing is thresholding the distance relative to several reference points, you can forgo the
sqrt()
and just square the thresholds.sqrt()
is a a very expensive function - avoiding it may significantly improve performance.