Re-write the GetDifferential using two sliding windows, sum_before and sum_after. The efficiency should be improved from O(N^2) to O(N). Here are the test results:
The original results: The updated results: