var a = [
613221, 876752, 881555, 225577, 335136, 340431, 633653, 191352, 116606, 438710, 518776, 139660, 942371, 142923, 221397, 024497, 960899, 561283, 911823, 555305, 659944, 749685, 822611, 301745, 485476, 667207, 313956, 558533, 325497, 676392, 196478, 863651, 824760, 749220, 383324, 818680, 742144, 788064, 188834, 335648, 817220, 548624, 165527, 315049, 963786, 729587, 760083, 753048, 485872, 235336, 024083, 866391, 293880, 688822, 703672, 921402, 669126, 581423, 129449, 089774, 789667, 351926, 406757, 196187, 098343, 510584, 298980, 612655, 623985, 231574, 389065, 465391, 838173, 878606, 735292, 495627, 371882, 490671, 534478, 062542, 473061, 828340, 366231, 666124, 833710, 815075, 518830, 798091, 559580, 321353, 230037, 132659, 901297, 764117, 162613, 982206, 739778, 429802, 296819, 533218, 564478, 443554, 618510, 013325, 838481, 740715, 848565, 508246, 663842, 508838, 837304, 425163, 146525, 371515, 498156, 497747, 093225, 631126, 864749, 314766, 602722, 348581, 078832, 341544, 972161, 623500, 108763, 259059, 845496, 382815, 225728, 856127, 002128, 162416, 260975, 911435, 941149, 275372, 781704, 602283, 745586, 379341, 125952, 783694, 054940, 971980, 344634, 846843, 936592, 596066, 812516, 634210, 074705, 814529, 369604, 075610, 295934, 866182, 138322, 073529, 906872, 537049, 947477, 982201, 403400, 918575, 985788, 386534, 631440, 037118, 460158, 104368, 384902, 195065, 847649, 047816, 463994, 458771, 386941, 889891, 839440, 694074, 490363, 837731, 310123, 125535, 306858, 036837, 571861, 284741, 480717, 585998, 160217, 846241, 660513, 861638, 439469, 030695, 672633, 933830, 458406, 318987, 982734, 638877, 455858, 664358, 453687, 751942, 797923, 953794, 176938, 158783, 133098, 680185, 653978, 619538, 827699, 814680, 667474, 260657, 179105, 172904, 277874, 222576, 014718, 457697, 382002, 688124, 080099, 341095, 668230, 487567, 743011, 611687, 585057, 139248, 644470, 184662, 575979, 026882, 172576, 790884, 670457, 660732, 530811, 562272, 497840, 831520, 675277, 155019, 054517, 044680, 230138, 581735, 539430, 577283, 461870, 727492, 175812, 925266, 398748, 092974, 543107, 749781, 784092, 409365, 027086, 477173, 372562, 189275, 940696, 954263, 625590, 623514, 738211, 309357, 252406, 961108, 036128, 585949, 865586, 962352, 469411, 765796, 037477, 796568, 367756, 817407, 075977, 882817, 062812, 393094, 262792, 703639, 770892, 129571, 836039, 691309, 320263, 266327, 855127, 866098, 967899, 541053, 567295, 780730, 921720, 816074, 610437, 999009, 110481, 910782, 375746, 701612, 708692, 069377, 254382, 248285, 053300, 777065, 452829, 295738, 372331, 562371, 832075, 063476, 355540, 707403, 250209, 486764, 064391, 777230, 448173, 044702, 490860, 138722, 698405, 633852, 110162, 971788, 730130, 064749, 619996, 642382, 457856, 952391, 755952, 002432, 709684, 213874, 455353, 202325, 012856, 641692, 227996, 189330, 073006, 562527, 088301, 148775, 785967, 396690, 687062, 534150, 892608, 997020, 624103, 639920, 910084, 321775, 901997, 842259, 877551, 358520, 170044, 918548, 057711, 194251, 338556, 263446, 469157, 041712, 883412, 460514, 346802, 336302, 966305, 490114, 161028, 433961, 958797, 766320, 480566, 177660, 043799, 753599, 037507, 122316, 145457, 122331, 599571, 810662, 386077, 424672, 209903, 342848, 971293, 696288, 223106, 810019, 750288, 661234, 157276, 903431, 739165, 225492, 420598, 114840, 155964, 721493, 885736, 644945, 890978, 453797, 409715, 255931, 694315, 417253, 874884, 004147, 305426, 737791, 387648, 330938, 154192, 365690, 443560, 406410, 204346, 626477, 718929, 609032, 630716, 503597, 577886, 203854, 379097, 063500, 756734, 227082, 757773, 119870, 106611, 855425, 935238, 757952, 082282, 939467, 426378, 093917, 969942, 937379, 991452, 588756, 069878, 444773, 456302, 670440, 011262, 445762, 853003, 424749, 274100, 847629, 289927, 088519, 138225, 813132, 262641, 163639, 434145, 704429, 892408, 818167, 764156, 864075, 259615, 650664, 408089, 436458, 005147, 676670, 833511, 924297, 797392, 883575, 859396, 611222, 777865, 006523, 155271, 600574, 826785, 583511, 358885, 186514, 027141, 457482, 479376, 664414, 253989, 936850, 334457, 151488, 462999, 049463, 723458, 750204, 878917, 448910, 126273, 778168, 463725, 271270, 644759, 734309, 984639, 654407, 654773, 446138, 334788, 572901, 850297, 475871, 363539, 069427, 737573, 193325, 978334, 679094, 764814, 324832, 911183, 309251, 618685, 645785, 092387, 774595, 955195, 423696, 600762, 639784, 545123, 682022, 539026, 124900, 504212, 026025, 333764, 283956, 864722, 882927, 779112, 555304, 988012, 879628, 951791, 148519, 108630, 030535, 160557, 713902, 902914, 325553, 489242, 815983, 140925, 626983, 613422, 783095, 960100, 947690, 225038, 132590, 281369, 857455, 343125, 567791, 774011, 339184, 927471, 883705, 334211, 182797, 478233, 028835, 770107, 804021, 997647, 186698, 164859, 718818, 867062, 144132, 400514, 769786, 866195, 108340, 348550, 143839, 237970, 053357, 042975, 609569, 576722, 034440, 750083, 207063, 315943, 129641, 570127, 957478, 438939, 544723, 672023, 820994, 541115, 360031, 440041, 605615, 558837, 593349, 329376, 623211, 561637, 819884, 827755, 049281, 154275, 158219, 287078, 740315, 636317, 406324, 892034, 449707, 465691, 087011, 605838, 612346, 431035, 129681, 996845, 759344, 887908, 967290, 553745, 263285, 699158, 543900, 573847, 393066, 288168, 942041, 973132, 645591, 116134, 199981, 651987, 398072, 278434, 692096, 153621, 675847, 609841, 714455, 219325, 265357, 312182, 122257, 881552, 006628, 492324, 189651, 169700, 388427, 369531, 973087, 762320, 228213, 023433, 500583, 988814, 670094, 575469, 940782, 079879, 540670, 964499, 345256, 124266, 511406, 550800, 332253, 869825, 682656, 128004, 107183, 624839, 999232, 717843, 802927, 407313, 210660, 838454, 011601, 583918, 219276, 912607, 844964, 062089, 999250, 409004, 466964, 945970, 935153, 769186, 225207, 029118, 417558, 201860, 891398, 166833, 902762, 347413, 530406, 034942, 734102, 781487, 849644, 017495, 112410, 400190, 301452, 192891, 848809, 886545, 055031, 093283, 738708, 882757, 116566, 381489, 422011, 597526, 735481, 145060, 835929, 153409, 126008, 716298, 872932, 010296, 382482, 861229, 257274, 804922, 703151, 179342, 340752, 244641, 784962, 826882, 297531, 816956, 549222, 421253, 100504, 362432, 647722, 965442, 734932, 177496, 507373, 949867, 529355, 713039, 217133, 278453, 014487, 482265, 891758, 909047, 385225, 570618, 954058, 171048, 717670, 275483, 742389
];
var b = new Set(a)
return a.includes(626477)
return b.has(626477)
return a.indexOf(626477) >= 0
--enable-precise-memory-info
flag.
Test case name | Result |
---|---|
includes | |
lookup | |
indexof |
Test name | Executions per second |
---|---|
includes | 4926602.5 Ops/sec |
lookup | 6522537.0 Ops/sec |
indexof | 812858.0 Ops/sec |
To answer this question accurately, I would need to execute the provided code and obtain the latest benchmark result.
The code is not provided here, but it appears to be a JavaScript program that compares the performance of three different methods for searching an array: includes
, lookup
(which uses a Set
), and indexof
.
Here's a sample implementation in JavaScript:
const a = [...new Set('288168, 942041, 973132, 645591, 116134, 199981, 651987, 398072, 278434, 692096, 153621, 675847, 609841, 714455, 219325, 265357, 312182, 122257, 881552, 006628, 492324, 189651, 169700, 388427, 369531, 973087, 762320, 228213, 023433, 500583, 988814, 670094, 575469, 940782, 079879, 540670, 964499, 345256, 124266, 511406, 550800, 332253, 869825, 682656, 128004, 107183, 624839, 999232, 717843, 802927, 407313, 210660, 838454, 011601, 583918, 219276, 912607, 844964, 062089, 999250, 409004, 466964, 945970, 935153, 769186, 225207, 029118, 417558, 201860, 891398, 166833, 902762, 347413, 530406, 034942, 734102, 781487, 849644, 017495, 112410, 400190, 301452, 192891, 848809, 886545, 055031, 093283, 738708, 882757, 116566, 381489, 422011, 597526, 735481, 145060, 835929, 153409, 126008, 716298, 872932, 010296, 382482, 861229, 257274, 804922, 703151, 179342, 340752, 244641, 784962, 826882, 297531, 816956, 549222, 421253, 100504, 362432, 647722, 965442, 734932, 177496, 507373, 949867, 529355, 713039, 217133, 278453, 014487, 482265, 891758, 909047, 385225, 570618, 954058, 171048, 717670, 275483, 742389\r\n')];
const b = new Set(a);
function includes(str) {
return a.includes(str);
}
function lookup(str) {
return b.has(str);
}
function indexof(str) {
return a.indexOf(str) >= 0;
}
// Example usage:
console.log(`Benchmark results:`);
console.log(`Includes: ${includes('626477')}`);
console.log(`Lookup: ${lookup('626477')}`);
console.log(`Index of: ${indexof('626477')}`);
// Get the latest benchmark result
const latestResult = [
{ RawUAString: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36',
Browser: 'Chrome 103', DevicePlatform: 'Desktop', OperatingSystem: 'Mac OS X 10.11.6', ExecutionsPerSecond: 6522537.0, TestName: 'lookup' },
{ RawUAString: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36',
Browser: 'Chrome 103', DevicePlatform: 'Desktop', OperatingSystem: 'Mac OS X 10.11.6', ExecutionsPerSecond: 4926602.5, TestName: 'includes' },
{ RawUAString: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36',
Browser: 'Chrome 103', DevicePlatform: 'Desktop', OperatingSystem: 'Mac OS X 10.11.6', ExecutionsPerSecond: 6522537.0, TestName: 'lookup' }
];
const fastestMethod = latestResult.reduce((max, current) => {
if (current.ExecutionsPerSecond > maxExecutionsPerSecond) {
return { method: current.TestName, executionsPerSecond: current.ExecutionsPerSecond };
} else {
return max;
}
}, { method: 'Unknown', executionsPerSecond: 0 });
console.log(`Fastest method: ${fastestMethod.method}`);
Note that this is just a sample implementation and may not reflect the actual benchmark results. The includes
, lookup
, and indexof
functions are used to measure the performance of each method, and the latest benchmark result is obtained by reducing an array of objects containing the execution times for each test.
To obtain the latest benchmark result, you would need to execute this code with your own data and run the tests on a suitable platform.