Open smilinazzo opened 6 months ago
@smilinazzo The performance of Array.includes would become slower as the list gets larger. The scenario can be where there are duplication of data. For example if in the log file we have 2 same events/lines (10,11,11,12,13), when comparing with the original file (10,11,12,13), the test would pass as the event exist in the original file. It should have failed as there are two “11” compared to the original file.
So, how could you improve the efficiency of this check then? is there a better way to do it?
one solution is to compare the counts/frequency of each event in the original file and log files.
https://github.com/Ikshi/assignment/blob/cdde9f40d9217ba45bb7440288e2cf3fa4e71ae3/test/test.js#L19
This is iterating through a list of 1M things looking for each thing in another list of 1M things. I'm curious what the performance of Array.includes is as this list gets larger.
Can you think of a scenario where this passes but the test should actually fail?