nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: alexcasalboni/aws-lambda-power-tuning
Pull request #152 (2021-12-29 10:34:17)

Sort durations numerically
By default sort() is ordering items alphabetically. This was causing some unexpected results when comparing when some cold start durations where ignored for one configuration and preserved for another.


Patch:
diff --git a/lambda/utils.js b/lambda/utils.js
index 7ecbe73..c8e05d5 100644
--- a/lambda/utils.js
+++ b/lambda/utils.js
@@ -403,7 +403,7 @@ module.exports.computeAverageDuration = (durations) => {
 
     // compute trimmed mean (discard 20% of low/high values)
     const averageDuration = durations
-        .sort() // sort numerically
+        .sort(function (a, b) {  return a - b;  }) // sort numerically
         .slice(toBeDiscarded, -toBeDiscarded) // discard first/last values
         .reduce((a, b) => a + b, 0) // sum all together
         / newN


Test patch:
diff --git a/test/unit/test-utils.js b/test/unit/test-utils.js
index 9e76c45..d2d801b 100644
--- a/test/unit/test-utils.js
+++ b/test/unit/test-utils.js
@@ -209,7 +209,7 @@ describe('Lambda Utils', () => {
 
     describe('computeAverageDuration', () => {
         const durations = [
-            1, 1, 2, 3, 3,
+            1, 1, 2, 3, 2000
         ];
 
         it('should return the average duration', () => {