function shuffle_arr(arr) {
const a = [arr];
for (let i = a.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[a[i], a[j]] = [a[j], a[i]];
}
return a;
}
var pre_sorted_int = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100];
var reverse_int = pre_sorted_int.reverse();
var shuffled_int = shuffle_arr(pre_sorted_int);
var pre_sorted_obj = [{"id":"0"},{"id":"1"},{"id":"2"},{"id":"3"},{"id":"4"},{"id":"5"},{"id":"6"},{"id":"7"},{"id":"8"},{"id":"9"},{"id":"a"},{"id":"b"},{"id":"c"},{"id":"d"},{"id":"e"},{"id":"f"},{"id":"10"},{"id":"11"},{"id":"12"},{"id":"13"},{"id":"14"},{"id":"15"},{"id":"16"},{"id":"17"},{"id":"18"},{"id":"19"},{"id":"1a"},{"id":"1b"},{"id":"1c"},{"id":"1d"},{"id":"1e"},{"id":"1f"},{"id":"20"},{"id":"21"},{"id":"22"},{"id":"23"},{"id":"24"},{"id":"25"},{"id":"26"},{"id":"27"},{"id":"28"},{"id":"29"},{"id":"2a"},{"id":"2b"},{"id":"2c"},{"id":"2d"},{"id":"2e"},{"id":"2f"},{"id":"30"},{"id":"31"},{"id":"32"},{"id":"33"},{"id":"34"},{"id":"35"},{"id":"36"},{"id":"37"},{"id":"38"},{"id":"39"},{"id":"3a"},{"id":"3b"},{"id":"3c"},{"id":"3d"},{"id":"3e"},{"id":"3f"},{"id":"40"},{"id":"41"},{"id":"42"},{"id":"43"},{"id":"44"},{"id":"45"},{"id":"46"},{"id":"47"},{"id":"48"},{"id":"49"},{"id":"4a"},{"id":"4b"},{"id":"4c"},{"id":"4d"},{"id":"4e"},{"id":"4f"},{"id":"50"},{"id":"51"},{"id":"52"},{"id":"53"},{"id":"54"},{"id":"55"},{"id":"56"},{"id":"57"},{"id":"58"},{"id":"59"},{"id":"5a"},{"id":"5b"},{"id":"5c"},{"id":"5d"},{"id":"5e"},{"id":"5f"},{"id":"60"},{"id":"61"},{"id":"62"},{"id":"63"}];
var reverse_obj = pre_sorted_obj.reverse();
var shuffled_obj = shuffle_arr(pre_sorted_obj);
var obj_sorter = (a,b) => {
if (a.id < b.id) {
return -1;
}
if (a.id > b.id) {
return 1;
}
return 0;
}
const sorted = pre_sorted_int.sort();
const sorted = reverse_int.sort();
const sorted = shuffled_int.sort()
const sorted = pre_sorted_obj.sort(obj_sorter);
const sorted = reverse_obj.sort(obj_sorter);
const sorted = shuffled_obj.sort(obj_sorter);
--enable-precise-memory-info
flag.
Test case name | Result |
---|---|
pre sorted int | |
reverse int | |
shuffled int | |
pre sorted obj | |
reverse obj | |
shuffled obj |
Test name | Executions per second |
---|---|
pre sorted int | 63477.5 Ops/sec |
reverse int | 63936.0 Ops/sec |
shuffled int | 72037.5 Ops/sec |
pre sorted obj | 78871.5 Ops/sec |
reverse obj | 92697.5 Ops/sec |
shuffled obj | 89026.0 Ops/sec |
It appears that we have a series of benchmarking tests to analyze. The objective is to determine which test case has the highest Execution Per Second (EPS) value.
To answer this question, I will examine each test case individually:
Based on the EPS values, it appears that the shuffled obj test case has the highest value, with an EPS of approximately 92.698 kg (I assume you meant "per second" instead of "per kilogram").
Therefore, my answer is:
The shuffled obj test case has the highest Execution Per Second value.