I found the following two functionality-same pieces of code have significantly different performance. The first ran 5ms while the second ran 45ms with same dataset. So what could impact the performance? Seems the second is translated to the first one, what happened in this translation?
Sorry I didn't use any performance comparison tool like JMH..
Arrays.sort(intervals, new Comparator<Interval>(){
public int compare(Interval a, Interval b){
return a.start - b.start;
}
});
Arrays.sort(intervals, (a, b) -> a.start - b.start);