Index: test/js-perf-test/TypedArrays/sort.js |
diff --git a/test/js-perf-test/TypedArrays/sort.js b/test/js-perf-test/TypedArrays/sort.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..aebc981e643cd2aefc9edfc6c138db88c5749a71 |
--- /dev/null |
+++ b/test/js-perf-test/TypedArrays/sort.js |
@@ -0,0 +1,33 @@ |
+// Copyright 2017 the V8 project authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+new BenchmarkSuite('Sort', [1000], [ |
+ new Benchmark('Sort', false, false, 0, |
+ sortLarge, sortLargeSetup, sortLargeTearDown), |
+]); |
+ |
+var size = 3000; |
+var initialLargeFloat64Array = new Array(size); |
+for (var i = 0; i < size; ++i) { |
+ initialLargeFloat64Array[i] = Math.random(); |
+} |
+initialLargeFloat64Array = new Float64Array(initialLargeFloat64Array); |
+var largeFloat64Array; |
+ |
+function sortLarge() { |
+ largeFloat64Array.sort(); |
+} |
+ |
+function sortLargeSetup() { |
+ largeFloat64Array = new Float64Array(initialLargeFloat64Array); |
+} |
+ |
+function sortLargeTearDown() { |
+ for (var i = 0; i < size - 1; ++i) { |
+ if (largeFloat64Array[i] > largeFloat64Array[i+1]) { |
+ throw new TypeError("Unexpected result!\n" + largeFloat64Array); |
+ } |
+ } |
+ largeFloat64Array = void 0; |
+} |