Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Optional chaining array access without local cache vars vs optional chaining array access with local cache vars
Testing with nested sensor data
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36
Browser:
Chrome 143
Operating system:
Windows
Device Platform:
Desktop
Date tested:
3 months ago
Test name
Executions per second
Optional chaining array access without local cache vars
19506678.0 Ops/sec
Optional chaining array access with local cache vars
27884092.0 Ops/sec
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
var sensorMsg = { "header": { "stamp": { "sec": 2222222222, "nanosec": 333333333 }, "frame_id": "" }, "pivot_timestamp": { "sec": 2222222222, "nanosec": 333333333 }, "pivot_name": "pivot_finger1", "camera_streams": [], "streams": [ { "finger_name": "finger1", "frames": [ { "header": { "stamp": { "sec": 2222222222, "nanosec": 333333333 }, "frame_id": "tactile_data" }, "sequence_idx": 999999, "system_hw_time_offset": 2323232323.232323, "system_hw_time_slope": 1, "mics": [ { "mic_hw_ts": 23423423423, "mic_name": "mic", "valid": true, "mic": [ 1070, 1150, 1006, 1000, 948, 1062, 1040, 1084, 1108, 1006, 1004, 1114, 972, 1182, 992, 882, 1098, 1168, 1490, 1494, 1018, 958, 920, 1194, 1104, 1340, 1208, 1276, 1098, 1414, 1300, 1196, 1386, 1680, 1546, 1500, 1500, 1220, 1620, 1316, 1698, 1534, 1784, 1592, 1358, 1292, 1880, 1626, 1736, 1568, 1830, 1592, 1620, 1508, 1998, 2188, 1720, 1784, 1952, 1886, 1816, 1990, 1862, 1646, 1658, 1842, 2140, 1770, 1966, 1966, 1766, 1776, 1802, 1840, 2130, 2148, 2260, 2014, 1764, 2286, 1894, 2038, 2036, 1956, 2222, 1876, 1978, 1772, 1996, 1772, 1730, 1646, 1580, 1900, 1858, 2004, 1750, 1842, 1568, 1616, 1714, 1674, 1346, 1530, 1558, 1540, 1748, 1396, 1496, 1436, 1326, 1540, 1410, 1368, 1356, 1662, 1432, 1922, 1402, 1632, 1242, 1592, 1666, 1292, 1334, 1518, 1368, 1344, 1438, 1586, 1542, 1390, 1576, 1364, 1126, 1588, 1426, 1542, 1326, 1484, 1420, 1378, 1322, 1502, 936, 1056, 1582, 1408, 1190, 1304, 1214, 1442, 1612, 1316, 1322, 1530, 1202, 1730, 1282, 1260, 1372, 1150, 1102, 1096, 1046, 1202, 1196, 1022, 1196, 1034, 1196, 1442, 1188, 1240, 1218, 1056, 1246, 1568, 878, 1200, 1110, 914, 1022, 998, 1194, 1494, 822, 940, 816, 770, 1062, 1280, 1064, 986, 850, 608, 926, 970, 868, 666, 764, 994, 816, 878, 792, 752, 982, 636, 804, 514, 1098, 594, 698, 538, 682, 640, 658, 752, 838, 608, 612, 698, 446, 526, 620, 758, 332, 502, 574, 238, 580, 498, 640, 464, 832, 862, 646, 686, 682, 700, 626, 600, 654, 400, 682, 646, 776, 618, 626, 428, 698, 504, 654, 710, 560, 1018, 816, 890, 642, 712, 436, 588, 470, 556, 398, 302 ] }, { "mic_hw_ts": 23423423423, "mic_name": "bcm", "valid": true, "mic": [ -26, -13, 32, 2, -42, 2, 11, -60, 64, 6, -40, 13, 33, 7, 0, -40, -4, 5, 21, 7, -2, -59, 20, 2, 20, -25, 12, -41, 27, 43, -4, 0, -64, 1, 3, 34, 35, -19, -66, 32, 45, 2, -41, 9, 23, 10, -28, -32, 43, 19, -9, -3, -28, -37, -19, 7, 41, 26, -31, 2, 9, 4, 8, -25, 6, 4, 9, -22, -27, 56, 13, 0, -9, -36, -27, 64, 3, -6, -1, -35, 29, -26, -32, 18, -4, 28, 32, 0, -47, -50, 38, 19, -30, -33, 34, 63, 1, -17, -67, 6, 36, 40, -36, -71, 69, 13, -62, -69, 64, 5, -20, 35, 4, -12, -12, -25, 24, -13, 51, 1, -80, 46, -8, -35, -43, 107, 5, -69, 22, -41, -39, 59, -48, 63, 42, -41, -35, -5, -62, 62, 11, -9, 19, 13, -5, -1, -27, -48, 23, 29, -9, -27, 3, 23, -18, -15, 40, 60, -44, -78, 19, -5, -28, 4, 12, 31, -38, 23, 4, 20, -6, -51, 3, 1, -7, 5, 2, -4, 4, 24, 8, -17, 33, -40, -12, 33, 31, -26, -28, 5, 19, -24, -14, 3, 0, -7, -2, 18, 45, -44, -12, 5, 9, 46, -20, -3, -32, -3, 35, 8, -26, 8, -37, -3, 4, 23, -4, -23, 27, 9, 31, -35, -34, 71, -31, 20, -4, -5, -20, -42, 9, 3, 36, 34, -29, -4, -14, 0, -32, 14, 8, 20, -34, 33, -8, -33, -12, 21, 35, -27, -11, 17, 61, -42, -22, 29, -22, -22, 21, 3, -16, 0, -15, 0, -2, 2 ] } ], "xl": [ { "xl_hw_ts": 23232323232, "xl_name": "xl", "valid": true, "xl_x": [ 79, 48, 73, 90, 81, 77, 70, 63, 57, 73, 79, 96, 84, 46, 67, 77, 72, 70, 67, 70, 76, 71, 105, 91, 60, 73, 106, 56, 58, 81, 105, 66, 66, 109, 124, 84, 75, 73, 63, 95, 103, 90, 58, 26, 58, 75, 31, 56, 88, 85, 54, 66, 94, 55, 50, 68, 62, 72, 75, 63, 60, 89, 77, 58, 43, 60, 74, 74, 45, 87, 109, 53, 77, 82, 60, 86, 73, 45, 75, 68, 71, 103, 72, 40, 56, 94, 94, 77, 94, 57, 63, 83, 78, 57, 105, 100, 40, 51, 93, 116, 85, 75, 93, 96, 72, 76, 78, 83, 45, 64, 93, 100, 73, 97, 102, 73, 63, 70, 84, 107, 102, 72, 88, 88, 77, 85, 66, 42, 69, 47, 44, 96, 74 ], "xl_y": [ 280, 278, 270, 307, 317, 287, 297, 303, 299, 305, 291, 270, 301, 302, 301, 283, 239, 256, 270, 241, 240, 256, 246, 246, 255, 213, 214, 268, 260, 258, 270, 279, 289, 277, 274, 274, 253, 278, 297, 299, 286, 292, 295, 305, 287, 278, 321, 320, 334, 338, 318, 292, 274, 328, 307, 284, 317, 312, 321, 293, 319, 337, 307, 295, 322, 303, 235, 282, 298, 278, 299, 346, 319, 268, 315, 315, 279, 292, 293, 306, 271, 272, 272, 274, 272, 274, 263, 261, 274, 249, 203, 239, 248, 238, 235, 239, 229, 210, 266, 258, 241, 228, 220, 238, 275, 238, 241, 258, 269, 235, 228, 269, 265, 238, 255, 233, 250, 258, 235, 253, 271, 287, 272, 277, 295, 282, 242, 266, 306, 304, 293, 264, 291 ], "xl_z": [ 7629, 7631, 7628, 7645, 7622, 7627, 7651, 7611, 7626, 7605, 7654, 7646, 7642, 7625, 7622, 7649, 7651, 7647, 7599, 7644, 7651, 7639, 7637, 7635, 7672, 7673, 7613, 7581, 7645, 7646, 7696, 7636, 7592, 7626, 7688, 7665, 7640, 7679, 7701, 7652, 7641, 7631, 7646, 7667, 7618, 7610, 7626, 7641, 7640, 7677, 7662, 7658, 7665, 7639, 7641, 7663, 7650, 7639, 7647, 7612, 7603, 7611, 7637, 7654, 7650, 7611, 7638, 7646, 7640, 7629, 7642, 7617, 7639, 7632, 7641, 7637, 7651, 7644, 7636, 7656, 7648, 7662, 7635, 7663, 7645, 7657, 7659, 7648, 7678, 7670, 7672, 7669, 7703, 7653, 7678, 7673, 7652, 7612, 7648, 7660, 7674, 7653, 7663, 7653, 7684, 7692, 7634, 7640, 7672, 7655, 7660, 7648, 7668, 7651, 7658, 7684, 7651, 7651, 7669, 7672, 7658, 7635, 7635, 7640, 7644, 7631, 7651, 7646, 7639, 7618, 7654, 7653, 7642 ] } ], "piezo": { "piezo_hw_ts": 13551192544, "piezo_name": "piezo", "valid": true, "piezo_h": 32, "piezo_w": 32, "piezo": [ 451, 311, 297, 134, 133, 248, 259, 153, 83, 108, 48, 13, 130, 337, 339, 347, 78, 80, 264, 107, 413, 513, 515, 373, 811, 233, 597, 329, 528, 481, 553, 925, 339, 270, 275, 132, 129, 244, 253, 152, 87, 106, 54, 17, 130, 335, 335, 347, 85, 92, 242, 125, 378, 498, 476, 373, 661, 246, 583, 307, 503, 461, 563, 853, 355, 281, 276, 128, 128, 242, 254, 155, 88, 107, 56, 16, 133, 341, 343, 352, 90, 90, 228, 112, 360, 522, 474, 402, 612, 243, 619, 294, 512, 460, 613, 888, 355, 278, 285, 126, 121, 244, 254, 165, 89, 104, 51, 14, 132, 362, 358, 377, 93, 92, 221, 106, 346, 553, 477, 439, 594, 261, 679, 266, 522, 455, 671, 822, 353, 262, 268, 125, 124, 239, 259, 164, 91, 104, 55, 14, 131, 385, 373, 403, 99, 89, 219, 107, 333, 614, 473, 483, 585, 268, 798, 265, 472, 431, 595, 757, 327, 247, 257, 132, 125, 222, 239, 158, 93, 104, 60, 20, 126, 413, 391, 432, 126, 104, 214, 112, 313, 689, 477, 577, 485, 261, 637, 257, 420, 403, 528, 670, 272, 226, 230, 127, 319, 288, 569, 116, 82, 250, 12, 1, 107, 208, 212, 231, 83, 111, 163, 147, 244, 297, 427, 266, 332, 211, 307, 219, 305, 328, 390, 483, 323, 257, 249, 132, 290, 317, 506, 125, 74, 216, 13, 2, 112, 222, 220, 239, 85, 107, 163, 151, 257, 317, 427, 268, 367, 221, 326, 231, 323, 344, 409, 508, 341, 275, 255, 131, 260, 323, 469, 138, 77, 203, 17, 1, 117, 230, 228, 243, 85, 111, 162, 152, 266, 334, 426, 289, 354, 223, 324, 225, 333, 351, 427, 542, 373, 285, 267, 123, 232, 350, 446, 146, 65, 175, 18, 2, 121, 256, 237, 255, 81, 110, 170, 150, 267, 342, 419, 292, 361, 227, 346, 230, 338, 369, 454, 591, 426, 304, 279, 118, 223, 386, 439, 155, 52, 167, 15, 2, 135, 271, 257, 264, 76, 102, 168, 143, 277, 361, 430, 309, 368, 231, 368, 231, 364, 392, 500, 658, 440, 336, 301, 113, 204, 439, 398, 140, 50, 149, 15, 0, 142, 292, 263, 274, 78, 105, 169, 132, 279, 381, 434, 321, 381, 237, 394, 228, 380, 415, 534, 743, 459, 353, 310, 98, 182, 496, 377, 134, 46, 143, 19, 3, 151, 326, 273, 287, 74, 104, 179, 132, 287, 400, 438, 332, 387, 231, 404, 228, 387, 431, 538, 835, 457, 375, 319, 95, 168, 564, 322, 129, 47, 128, 29, 2, 168, 326, 276, 283, 74, 107, 176, 135, 295, 399, 428, 334, 384, 236, 402, 223, 396, 448, 533, 807, 477, 416, 339, 87, 150, 493, 300, 135, 61, 130, 35, 1, 175, 333, 270, 293, 75, 103, 178, 132, 294, 406, 427, 341, 377, 236, 408, 227, 403, 474, 543, 828, 514, 461, 358, 66, 133, 450, 286, 139, 63, 118, 36, 1, 187, 342, 272, 295, 73, 102, 179, 127, 292, 416, 428, 355, 391, 232, 436, 217, 420, 492, 545, 870, 503, 484, 390, 46, 121, 435, 282, 143, 59, 122, 38, 1, 205, 354, 278, 296, 71, 99, 183, 123, 300, 429, 433, 356, 393, 236, 454, 214, 438, 531, 563, 925, 494, 431, 446, 44, 116, 396, 269, 138, 64, 117, 41, 2, 231, 372, 283, 310, 73, 96, 179, 120, 304, 440, 439, 366, 400, 226, 455, 210, 462, 568, 590, 968, 457, 389, 437, 65, 117, 351, 264, 146, 69, 107, 50, 5, 211, 349, 285, 297, 72, 96, 180, 134, 310, 422, 430, 349, 381, 231, 452, 213, 465, 591, 588, 852, 454, 371, 443, 64, 113, 335, 266, 155, 72, 105, 47, 8, 186, 336, 277, 297, 73, 104, 180, 130, 304, 416, 428, 352, 384, 225, 456, 200, 490, 654, 605, 821, 461, 355, 457, 69, 111, 309, 261, 156, 79, 109, 48, 8, 174, 321, 284, 298, 79, 103, 179, 132, 301, 416, 438, 347, 387, 224, 459, 203, 517, 719, 635, 784, 458, 329, 438, 76, 110, 298, 249, 149, 82, 107, 56, 7, 163, 317, 272, 292, 82, 99, 175, 132, 302, 409, 428, 341, 382, 223, 464, 188, 555, 851, 584, 726, 447, 306, 392, 95, 115, 274, 251, 153, 83, 104, 59, 15, 154, 300, 279, 283, 80, 105, 185, 144, 300, 399, 420, 336, 368, 220, 471, 192, 644, 711, 544, 661, 449, 289, 349, 101, 118, 259, 239, 157, 93, 104, 61, 19, 136, 280, 260, 278, 80, 103, 175, 151, 296, 387, 417, 329, 357, 222, 466, 213, 549, 604, 511, 605, 439, 277, 323, 118, 119, 236, 232, 158, 97, 109, 64, 28, 131, 260, 249, 258, 86, 117, 174, 151, 278, 357, 398, 314, 333, 228, 424, 219, 490, 532, 460, 533, 436, 248, 292, 122, 115, 218, 213, 151, 103, 106, 67, 33, 110, 233, 241, 254, 93, 123, 168, 164, 270, 337, 391, 294, 309, 223, 375, 223, 440, 479, 435, 492, 371, 231, 235, 133, 128, 210, 221, 156, 99, 108, 67, 28, 127, 406, 412, 339, 93, 114, 218, 132, 306, 628, 357, 637, 354, 240, 568, 240, 354, 359, 471, 588, 366, 231, 243, 133, 123, 219, 226, 158, 93, 100, 63, 29, 129, 388, 403, 365, 91, 110, 225, 134, 323, 610, 371, 545, 368, 251, 675, 242, 365, 371, 497, 622, 361, 242, 247, 134, 127, 219, 235, 157, 98, 105, 59, 25, 131, 368, 405, 382, 86, 113, 240, 132, 333, 579, 376, 487, 364, 246, 598, 241, 368, 367, 520, 657, 361, 239, 248, 133, 123, 223, 226, 159, 103, 104, 62, 23, 137, 361, 411, 423, 86, 111, 247, 124, 351, 591, 392, 458, 374, 243, 545, 247, 364, 370, 512, 713, 351, 237, 249, 123, 129, 222, 234, 159, 93, 103, 59, 21, 152, 384, 449, 455, 79, 103, 283, 114, 369, 624, 398, 452, 382, 240, 535, 243, 375, 377, 494, 738, 402, 252, 258, 121, 123, 239, 243, 161, 91, 103, 58, 17, 167, 411, 516, 551, 65, 88, 320, 92, 410, 725, 446, 467, 425, 243, 555, 251, 392, 398, 506, 847 ] } } ] } ] }
Tests:
Optional chaining array access without local cache vars
var parseSensorData1 = (msg) => ({ 0: { piezo: msg.streams[0]?.frames[0]?.piezo?.piezo, acoustic: msg.streams[0]?.frames[0]?.mics[0]?.mic, accel: { x: msg.streams[0]?.frames[0]?.xl[0]?.xl_x, y: msg.streams[0]?.frames[0]?.xl[0]?.xl_y, z: msg.streams[0]?.frames[0]?.xl[0]?.xl_z, }, }, 1: { piezo: msg.streams[1]?.frames[0]?.piezo?.piezo, acoustic: msg.streams[1]?.frames[0]?.mics[0]?.mic, accel: { x: msg.streams[1]?.frames[0]?.xl[0]?.xl_x, y: msg.streams[1]?.frames[0]?.xl[0]?.xl_y, z: msg.streams[1]?.frames[0]?.xl[0]?.xl_z, }, }, 2: { piezo: msg.streams[2]?.frames[0]?.piezo?.piezo, acoustic: msg.streams[2]?.frames[0]?.mics[0]?.mic, accel: { x: msg.streams[2]?.frames[0]?.xl[0]?.xl_x, y: msg.streams[2]?.frames[0]?.xl[0]?.xl_y, z: msg.streams[2]?.frames[0]?.xl[0]?.xl_z, }, }, 3: { piezo: msg.streams[3]?.frames[0]?.piezo?.piezo, acoustic: msg.streams[3]?.frames[0]?.mics[0]?.mic, accel: { x: msg.streams[3]?.frames[0]?.xl[0]?.xl_x, y: msg.streams[3]?.frames[0]?.xl[0]?.xl_y, z: msg.streams[3]?.frames[0]?.xl[0]?.xl_z, }, }, 4: { piezo: msg.streams[4]?.frames[0]?.piezo?.piezo, acoustic: msg.streams[4]?.frames[0]?.mics[0]?.mic, accel: { x: msg.streams[4]?.frames[0]?.xl[0]?.xl_x, y: msg.streams[4]?.frames[0]?.xl[0]?.xl_y, z: msg.streams[4]?.frames[0]?.xl[0]?.xl_z, }, }, }) parseSensorData1(sensorMsg)
Optional chaining array access with local cache vars
var parseSensorData2 = (msg) => { const s = msg.streams; const s0 = s?.[0]; const f0 = s0?.frames?.[0]; const xl0 = f0?.xl?.[0]; const s1 = s?.[1]; const f1 = s1?.frames?.[0]; const xl1 = f1?.xl?.[0]; const s2 = s?.[2]; const f2 = s2?.frames?.[0]; const xl2 = f2?.xl?.[0]; const s3 = s?.[3]; const f3 = s3?.frames?.[0]; const xl3 = f3?.xl?.[0]; const s4 = s?.[4]; const f4 = s4?.frames?.[0]; const xl4 = f4?.xl?.[0]; return { 0: { piezo: f0?.piezo?.piezo, acoustic: f0?.mics?.[0]?.mic, accel: { x: xl0?.xl_x, y: xl0?.xl_y, z: xl0?.xl_z }, }, 1: { piezo: f1?.piezo?.piezo, acoustic: f1?.mics?.[0]?.mic, accel: { x: xl1?.xl_x, y: xl1?.xl_y, z: xl1?.xl_z }, }, 2: { piezo: f2?.piezo?.piezo, acoustic: f2?.mics?.[0]?.mic, accel: { x: xl2?.xl_x, y: xl2?.xl_y, z: xl2?.xl_z }, }, 3: { piezo: f3?.piezo?.piezo, acoustic: f3?.mics?.[0]?.mic, accel: { x: xl3?.xl_x, y: xl3?.xl_y, z: xl3?.xl_z }, }, 4: { piezo: f4?.piezo?.piezo, acoustic: f4?.mics?.[0]?.mic, accel: { x: xl4?.xl_x, y: xl4?.xl_y, z: xl4?.xl_z }, }, }; }; parseSensorData2(sensorMsg)