Linear DOM Replacement

Benchmark created by Sufian Rhazi on


Preparation HTML

<div class="testcase depth-0"></div>
<div class="testcase depth-1"></div>
<div class="testcase depth-2"></div>
<div class="testcase depth-3"></div>
<div class="testcase depth-4"></div>
<div class="testcase depth-5"></div>
<div class="testcase depth-6"></div>
<div class="testcase depth-7"></div>
<div class="testcase depth-8"></div>
<div class="testcase depth-9"></div>
<div class="testcase depth-10"></div>
<div class="testcase depth-11"></div>
<style>
.testcase {
  display: none;
}
</style>
<script>

function build(element, depth, startIndex, children) {
  if (depth === 0) {
    for (var i = 0; i < children; ++i) {
      var child = document.createElement('div');
      child.textContent = startIndex + i;
      element.appendChild(child);
    }
  } else {
    var l = document.createElement('div');
    build(l, depth - 1, startIndex, children / 2);
    var r = document.createElement('div');
    build(r, depth - 1, startIndex + children / 2, children / 2);
    element.appendChild(l);
    element.appendChild(r);
  }
}

build(document.querySelector('.depth-0'), 0, 0, 2048);
build(document.querySelector('.depth-1'), 1, 0, 2048);
build(document.querySelector('.depth-2'), 2, 0, 2048);
build(document.querySelector('.depth-3'), 3, 0, 2048);
build(document.querySelector('.depth-4'), 4, 0, 2048);
build(document.querySelector('.depth-5'), 5, 0, 2048);
build(document.querySelector('.depth-6'), 6, 0, 2048);
build(document.querySelector('.depth-7'), 7, 0, 2048);
build(document.querySelector('.depth-8'), 8, 0, 2048);
build(document.querySelector('.depth-9'), 9, 0, 2048);
build(document.querySelector('.depth-10'), 10, 0, 2048);
build(document.querySelector('.depth-11'), 11, 0, 2048);

function findAndReplace(root, depth, size, index, replacementElement) {
  if (depth === 0) {
    root.replaceChild(replacementElement, root.childNodes[index]);
  } else {
    var mid = size / 2;
    if (index < mid) {
        findAndReplace(root.childNodes[0], depth - 1, mid, index, replacementElement);
    } else {
        findAndReplace(root.childNodes[1], depth - 1, mid, index - mid, replacementElement);
    }
  }
}

window.randomness = [844,960,1441,736,409,424,1556,1462,555,1417,821,1129,1999,1568,993,783,530,963,344,1769,385,619,851,755,1319,925,1939,476,1247,1814,1575,300,831,1408,654,288,209,1368,1405,1951,799,675,1495,2019,1526,1418,1158,1617,627,27,1883,1272,43,128,2034,907,152,2039,316,662,1423,171,919,1200,367,407,107,1856,910,1816,1069,862,26,1141,1588,478,1781,1078,1327,1984,1910,1896,1970,139,213,1696,2,1335,1647,480,294,964,130,886,1582,1267,370,1195,5,1108,1398,1459,1560,258,1075,616,1949,612,1505,1180,609,812,1232,1921,1232,550,12,1721,1736,437,1193,1297,1454,1755,1152,1221,1755,1516,272,226,231,231,765,1698,1507,633,612,507,50,712,1921,1994,535,1127,776,1143,1819,130,257,226,1940,1160,1774,240,1856,1523,1751,808,133,1936,496,307,1811,1312,334,1068,1525,313,2045,170,872,618,1815,472,1849,1131,1363,129,1299,1460,1235,279,265,1132,1043,1198,1192,1569,1125,471,1475,190,1009,1039,1794,1452,1169,1305,170,617,1784,1167,1946,1753,1278,909,1764,1090,606,1692,1357,1761,1270,3,629,60,1578,1904,2028,357,1135,394,1202,40,487,1253,1676,996,1901,778,1573,1708,1620,599,801,985,1978,622,1960,429,1292,1509,487,1185,106,85,1361,298,1046,1202,2029,343,270,1497,1023,797,828,272,1413,521,1670,796,645,400,1627,1779,383,1753,990,773,204,212,1247,1411,1342,2030,876,1879,1761,1371,131,1653,2006,969,1910,1481,1312,390,498,881,1376,759,248,262,1166,105,667,2041,1372,198,1663,1292,332,524,1424,1697,1219,2044,1389,1877,1645,614,1047,1027,946,1049,275,1953,1401,411,1148,198,749,1224,606,1922,663,1004,1922,1389,1937,1022,79,665,1166,558,862,1597,633,775,1653,138,849,269,232,1094,1360,1842,493,285,1822,2039,1973,1711,771,964,1970,499,1163,1708,879,1504,788,773,625,960,276,429,866,782,594,319,1067,1910,1733,1489,1319,746,975,1829,1596,1254,168,689,894,1981,21,63,986,81,1622,9,1536,189,43,1451,1833,467,1556,1370,2044,1612,1241,1954,704,1105,1703,571,806,1934,573,1069,571,1107,1238,1241,1696,196,1363,1400,174,1336,1256,1913,172,1511,521,1455,375,1924,747,832,1577,1520,1008,850,23,956,1612,992,1711,108,1259,1566,1006,1762,1913,1790,1140,1953,67,461,1540,1057,1985,1100,1757,33,1051,987,204,179,1124,50,1351,303,1352,1800,1299,1399,1837,683,1457,256,893,1646,329,1681,1223,1738,1600,872,1203,1536,1856,1215,1390,674,144,808,1546,1342,728,165,295,2040,472,2010,1052,1484,1880,2002,488,268,1855,1976,903,1535,1922,159,1258,789,68,2025,1843,607,1452,832,1192,50,228,1235,699,1705,233,1665,1126,284,1872,134,124,1224,1189,1724,1060,1697,557,1977,2002,1519,1242,385,1373,1197,685,961,1529,465,213,826,136,645,1880,533,1374,354,332,1410,1443,1872,792,294,183,645,1849,1459,499,213,511,192,801,1102,911,255,1564,950,558,1999,1304,896,33,1465,181,1866,296,225,496,1065,2042,1285,881,2023,527,891,1886,1130,627,1225,1598,948,929,1677,1312,149,10,1592,48,1328,1543,1014,478,1995,639,129,1377,440,1428,934,593,1377,712,627,911,1836,1750,110,469,1137,1166,1348,1376,2026,2000,182,1527,1944,35,824,1970,713,688,1117,1827,185,705,1551,1051,1470,378,1550,1728,377,211,466,736,1614,327,1985,1187,491,119,1740,744,269,1015,1057,1795,595,870,1192,1533,1464,763,64,645,1970,470,1913,898,1072,1002,822,229,1484,1794,922,1071,15,1762,1445,1372,1404,1485,1150,1810,191,1904,1641,829,1150,1907,147,1443,608,221,1076,353,1885,1089,277,411,313,965,300,1139,1367,1307,1291,8,38,2009,1952,1994,769,1070,796,813,839,1421,1351,262,1864,213,1694,798,1476,979,1742,1659,777,1802,1825,1688,0,180,958,1387,1272,1052,366,1574,1774,1975,886,48,1416,448,1161,431,378,931,1447,295,591,655,763,1612,169,570,1054,715,878,200,394,1502,1454,1340,1877,676,12,899,898,970,673,620,1585,952,910,1657,7,1254,383,783,833,1757,1567,2029,1729,774,1393,1123,1734,973,1143,1111,580,1829,1046,1619,1288,1291,1386,1139,709,1850,1411,604,238,1699,1377,1488,50,1837,489,536,1465,947,1062,267,560,964,396,1166,675,642,229,1774,606,2015,1733,810,205,1870,1478,1196,1829,125,577,697,785,1267,730,1792,553,459,1368,728,1089,1909,1388,1285,1561,430,2032,315,534,1207,1525,1883,295,1092,1410,1699,1237,1175,88,232,1560,388,1407,1832,1003,924,390,1587,323,1559,518,1045,984,399,1128,1617,1953,1018,1626,353,989,114,54,99,1416,567,28,1888,324,1632,1150,802,1545,214,1111,1749,259,1639,1644,426,1533,202,171,721,7,1125,1798,1795,126,1122,1304,607,1587,1191,316,1952,232,1036,1956,1466,558,1803,804,272,352,1924,1460,1789,1568,23,1447,899,738,1834,114,1520,2033,592,607,1438,725,16,469,1346,72,348,505,1612,433,949,1554,1109,1303,1657,830,139,1032,1528,1918,1792,1543,194,1638,879,304,1912,1927,128,709,1283,1355,548,1599,2034,751,1324,223,678,621,1993,332,1866,1952,857,842,435,224,364,140,605,1575,1193,1180,1186,1184,746,746,1914,782,837,1363,1342,1957,827,1990,817,635,1238,1906,1379,848,1532,336,586,2043,1657,1904,150,1438,1701,120,919,999,1262,1535,1017,1092,1754,1501,1218,238,124,1149,782,579,1985,686,500,2040,1868,1210,1568,1152,471,813,233,2042,954,1296,1689,1549,968,316,314,1065,1365,1983,642,363,1947,996,2020,1041,1660,1482,1786,618,17,1609,1344,423,844,1280,524,200,1339,1637,1066,1580,192,1961,815,522,1865,259,1628,494,1016,1290,1942,913,1643,1860,1849,700,9,850,1068,335,231,30,1043,315,1406,1410,644,731,795,1498,533,1652,1273,1731,833,1593,876,565,1662,883,185,728,1380,1365,353,598,85,175,437,1340,1983,920,1640,1724,1137,182,660,513,881,90,842,550,1325,57,871,559,1340,1908,376,1326,904,1529,960,1775,1892,416,238,1323,239,1851,561,532,1726,1515,1806,824,992,1492,1778,421,1508,1210,1457,216,867,761,644,121,740,739,972,1700,55,146,1086,1746,630,1667,1589,795,1496,1663,457,288,1296,543,1906,1427,129,1316,174,1466,1060,1482,1432,1593,1472,365,191,1584,2041,304,287,1555,1665,913,660,579,1143,1325,1557,1220,467,326,687,828,1905,847,1360,488,1791,1347,95,930,1242,841,1892,865,125,1702,1538,1095,176,1844,361,2029,1574,1464,155,1481,960,1717,199,1649,125,296,1782,1489,1662,1086,1455,1164,47,1076,591,505,1981,1241,569,1852,1532,138,486,1252,1351,259,1341,1473,893,448,357,1040,350,1786,1297,1625,1633,305,393,1366,1071,375,1537,225,458,1205,1162,861,1831,812,903,1781,1197,371,347,319,1751,577,52,2023,1542,175,931,721,1081,2037,942,1912,815,1788,1256,321,1082,624,442,373,862,1941,953,910,1460,177,1974,182,899,1237,1100,2009,1007,1475,1729,16,1320,1373,359,1727,1582,1112,296,1767,503,574,1944,1340,1921,741,1219,1821,2024,251,276,2005,134,1440,1702,286,1533,294,1488,786,944,586,1867,1161,1924,253,1934,562,160,1994,231,1586,1256,934,1209,1790,1850,576,382,1428,1543,32,531,2033,744,1103,1120,1416,1412,329,699,261,847,857,1479,145,1741,543,415,1739,502,670,626,1388,878,1821,1078,915,941,473,244,1576,884,436,1543,1007,2020,956,159,1555,263,1674,1708,1362,1832,2028,1666,749,1787,1545,1680,1430,1494,577,1315,128,1247,630,918,1772,727,1454,1119,64,123,502,1993,1908,992,273,393,1873,98,643,1238,206,1688,465,1208,210,950,1234,966,1738,13,981,242,1317,864,683,1521,1275,986,1803,1011,2027,1596,1924,473,1006,1255,1749,1474,843,503,794,1302,1015,1444,1987,983,151,1889,578,1837,630,1549,239,860,744,1874,1141,1016,674,1758,930,1601,345,1112,1665,422,1378,357,954,969,1803,1676,1193,66,589,1529,1443,950,1814,1251,1611,174,1362,696,1311,946,848,1312,1971,157,9,897,1940,682,1123,872,895,1549,1273,1883,1422,149,419,1707,18,601,1854,1997,1945,677,2018,507,909,171,298,1054,1303,28,1479,1533,676,201,1750,1702,1849,809,100,1039,163,327,444,318,1656,1379,976,183,1181,1179,1775,224,1309,605,814,578,494,1284,1707,600,435,1051,149,832,1877,304,142,73,523,1697,874,1346,855,508,376,458,341,1440,1140,1866,1656,443,458,1688,2002,1296,933,336,979,1040,913,293,426,360,1458,484,736,1800,512,156,1672,1804,812,2037,478,1292,1100,701,1300,1131,249,1245,597,108,81,619,140,715,140,1554,927,1549,1661,120,1907,2,724,98,565,698,1106,493,1310,762,609,218,889,1931,1068,1443,1299,1250,523,1207,802,507,48,1075,1002,16,305,1325,1411,35,1351,1830,1871,1915,597,207,916,918,1034,1323,1411,1610,53,1921,229,1845,365,872,107,1091,566,898,926,1278,442,841,1906,1603,772,638,419,1986,93,1525,1952,53,161,1418,398,2023,1776,267,803,1524,1348,1437,1897,571,718,167,1353,1362,1777,1104,1288,1812,812,1386,912,450,1949,225,485,151,1696,1747,488,763,753,608,1945,54,812,550,180,1913,1783,1451,556,881,1485,1092,29,1266,1672,636,1504,1714,493,101,1116,1592,1691,1039,2034,1259,1576,2035,635,1957,1580,1028,425,1344,1910,729,82,161,894,1598,104,1622,65,401,1932,103,1825,1511,323,352,1603,1200,503,1168,1568,1189,52,1919,360,68,192,8,1258,88,1496,1840,1710,1552,502,333,1819,289,1561,1003,756,110,1482,1980,1497,1878,1989,605,54,1295,1971,1586,791,127,1935,1553,1059,1237,1425,442,1607,210,1907,313,811,2017,1379,1077,2005,594,857,1688,592,461,1917,742,1959,281,1483,671,598,1414,914,47,1973,870,1345,535,1994,1851,1232,1639,1575,493,200,1720,795,11,795,1484,183,450,1795,514,418,1062,927,83,1249,1106,2014,933,1909,1240,664,704,750,541,1967,1720,1617,119,1192,88,1961,1268,1838,1773,1307,350,98,1509,302,1494,2025,1719,985,1279,305,1244,772,1153,41,2033,1717,410,770,1529,1071,382,1330,983,1203,1484,1867,1494,1133,1611,821,602,205,1043,166,1899,1908,1630,1206,699,747,407,685,1174,1718,1714,701,383,1249,334,1204,238,159,1925,621,1956,1587,200,1882,1611,1256,139,524,1118,1106,1313,407,991,1194,1001,1109,337,1972,1483,1807,1842,1655,1205,14,1487,449,308,393,32,1056,444,461,827,1518,788,497,1969,1966,1987,1853,198,1610,851,2020,962,62,1984,169,641,916,468,1323,1785,1013,134,1021,1257,1337,1684,500,1983,1114,809,988,1459,1967,889,607,478,80,453,664,1583,377,746,1223,511,331,1371,1829,268,285,1375,181,122,594,1129,755,727,457,691,1952,95,1433,471,518,270,173,762,819,1216,991,1376,1410,54,323,231,499,200,1480,313,643,633,1744,1245,1442,1837,833,96,100,642,442,1910,1466,457,1270,8,32,1387,1481,1309,1103,1031,1050,1287,1764,1399,1779,604,94,882,1444,1511,788,1538,368,1012,35,993,350,1872,871,395,1969,33,1490,785,1630,1311,1684,1931,1053,1868,1412,208,1363,1771,1104,1731,544,770,1660,1214,1626,167,1046,1023,1478,1860,1040,819,1914,1994,572,108,1408,1688,1701,2045,832,412,1391,1483,1030,1925,1446,1440,1173,1039,599,1018,392,247,34,1427,749,1813,1496,1415,1736,72,319,1635,1100,182,1605,1071,63,1757,1215,451,211,1914,1484,1347,1541,1996,293,1546,1874,1271,348,362,1590,1552,946,1855,2027,497,453,1543,1769,1329,1814,544,420,241,314,611,2010,481,1751,941,1239,454,1453,532,1272,1676,902,1171,400,681,1857,98,167,477,830,1759,1820,1011,1181,1273,935,1346,542,497,1846,1285,157,542,28,1497,1949,83,1292,1166,211,104,615,1315,1951,1202,1380,1871,1548,1557,189,1476,331,591,571,1677,1498,537,1532,1572,1934,1111,1800,243,2,211,213,1568,1637,378,224,112,154,692,1374,2024,1466,1390,1321,1882,2017,1238,7,1033,421,400,2042,89,644,406,673,990,148,1550,374,1736,1539,671,48,791,895,1856,1470,948,278,1201,1463,923,1775,15,1196,471,1445,145,919,1857,1411,183,1868,77,1845,37,1439,22,653,1532,995,1734,416,446,1348,747,341,1604,1522,1757,1995,463,1524,643,1300,676,1953,1360,1132,782,1574,507,461,521,1937,159,1109,245,216,1622,52,1556,1534,155,1451,914,1627,1017,1266,904,1507,554,1116,571,742,310,1919,338,793,1415,1716,825,1472,1672,836,1374,390,192,59,1242,1740,1617,745,1212,1266,810,970,1604,313,1062,1946,1158,853,1822,901,1656,1020,511,2037,1541,761,695,352,268,1147,410,512,916,1772,303,74,2023,785,1208,1913,1537,698,850,1413,1621,633,1830,1336,1668,2044,652,1782,1923,1249,280,736,321,168,990,1676,291,1291,1624,786,27,1213,1044,1150,781,316,75,1582,1893,736,1622,768,1460,226,338,903,1171,1586,1985,248,1790,346,386,827,1316,1334,1881,1038,720,649,1835,403,1158,950,263,923,205,276,1119,439,1708,1682,970,837,553,89,1146,1623,59,1542,1868,741,1627,1018,1628,1073,366,1201,1487,100,1135,2002,373,1686,1296,263,498,1707,320,972,770,1148,1215,1385,476,955,1743,1395,1262,1020,1071,800,842,1187,975,1919,1907,1739,1819,1494,1553,1568,1631,179,523,535,3,100,1665,370,1970,191,2037,1359,836,1150,1914,1362,1939,1685,1755,1793,432,1954,1846,1346,1038,378,1188,1169,1934,565,1490,1307,853,1672,44,1140,752,1251,975,1739,43,1066,669,1376,1700,1645,899,20,403,2024,569,489,2027,1121,1850,389,1044,1310,1536,305,465,1162,463,1621,1850,1858,1709,1628,85,166,1681,749,978,1166,1551,1597,210,1673,29,1560,612,770,998,281,117,852,933,1964,1214,239,190,670,1313,1570,1142,1810,710,1115,724,941,1903,1016,1029,1190,1889,1296,182,1226,69,1933,1515,1760,808,1568,1270,1273,1910,281,624,1416,1712,402,1425,1686,1787,1839,1413,1002,967,185,1185,1697,1877,1550,1580,1282,895,329,939,249,286,557,1155,849,975,814,774,1088,269,1776,398,212,1493,869,1804,627,1451,327,177,565,330,1353,979,77,356,273,79,83,1776,1154,1590,498,1358,1604,1800,1336,370,1983,1275,830,708,1165,1058,1288,322,1020,568,1285,1277,1080,253,1830,1609,1899,1920,2045,2002,1582,1430,171,921,311,860,759,686,1931,962,427,1721,1221,876,231,1993,975,414,926,577,482,1632,815,282,1576,1806,1555,1095,708,1003,1753,823,1136,1990,283,2041,743,1654,113,635,1997,211,1395,401,727,397,754,105,1508,463,1948,1486,192,688,774,1575,60,1754,72,1329,770,2016,285,528,99,1109,1134,1674,2044,1466,105,1712,904,1017,1448,676,1891,1801,11,845,1347,1358,1802,1894,1775,1713,486,643,2015,1590,1024,1195,2043,15,134,512,268,1538,1134,1546,571,1235,1799,1618,1657,500,680,1902,1958,2004,1850,2025,539,1218,2012,1381,1845,120,712,1666,1007,665,1095,317,1481,1719,416,1057,1150,2020,804,1041,272,522,1094,1254,593,1082,1276,798,262,1237,533,1283,1635,803,0,1783,298,1312,395,1702,906,602,1646,396,2026,1831,1527,356,973,89,1692,131,1539,361,604,841,1292,1767,1873,1387,1137,1933,336,1307,284,1538,513,1258,174,1774,1113,1580,1693,289,280,1473,218,455,774,1378,1510,506,1173,1070,1918,1033,1668,252,303,1759,393,294,1648,272,22,1102,221,1022,364,741,1213,864,1747,1118,1442,335,1659,824,1999,280,369,228,616,1624,1361,634,1362,479,659,139,1599,113,565,1317,521,698,896,957,258,1775,1691,2040,1679,310,846,1507,533,178,1183,1392,913,776,282,6,217,1643,661,1667,1592,983,1237,926,472,311,642,231,17,733,1301,492,1090,690,141,960,1860,1758,508,1671,150,846,1370,1802,750,2044,1390,1334,480,108,581,1912,1615,1973,1736,661,1215,338,322,2040,254,330,1035,1286,683,1073,877,607,2039,1766,1900,284,1753,2006,1238,103,539,973,1661,1255,1592,351,299,852,1072,1791,1180,925,1911,1924,1554,1661,1752,501,361,842,1202,830,731,880,1940,2012,2011,1141,1619,1539,342,1336,726,1245,1115,1356,957,435,388,770,474,1997,934,411,579,1788,1191,1047,1814,997,1725,1079,164,1749,368,209,13,176,60,1122,187,1909,1603,1684,1771,775,1481,600,318,42,883,1073,301,11,427,979,642,1642,1845,1143,1925,1093,173,789,1198,1736,1049,67,873,1144,875,1565,97,1397,578,1645,1345,1240,2033,1623,306,654,1842,2014,897,1451,1939,1089,627,1258,1024,1822,1053,1031,372,432,1037,1293,1953,1916,1180,1728,323,78,1596,1770,1525,942,913,35,1629,734,1208,1718,1641,2023,453,1924,1477,80,1835,189,1982,237,925,550,1644,1638,185,372,43,1739,1787,1283,1222,1501,81,1771,1849,532,1234,1332,700,1485,1431,946,1689,1029,2009,1037,299,1554,1691,935,458,211,148,1904,1624,869,452,768,1139,586,1641,1510,1232,1577,1144,1411,500,183,1131,1607,1353,1099,1157,1819,2040,1242,1618,74,1066,145,1236,45,1046,1978,266,260,1539,496,1195,1039,655,218,1429,290,1623,1199,871,163,1845,1065,172,1945,1596,1950,1429,1064,698,1574,1285,657,485,1655,255,816,2024,1793,1172,1637,1881,1408,1474,1851,1899,1373,378,282,982,877,1856,894,1120,1166,399,1168,1259,1872,400,2024,1145,1800,159,1449,1898,657,716,1322,201,831,1853,930,540,1083,422,876,963,1533,1872,1953,1171,1781,333,1033,841,1593,2026,918,921,1233,1550,627,1622,1539,1057,178,2032,1865,1503,601,1400,1862,36,1406,662,1343,801,1906,445,2027,345,1039,418,928,925,1407,1081,1520,1309,1729,1243,702,1038,111,1544,1367,805,1749,1168,355,686,1758,1840,1592,1755,142,1241,1110,1667,1102,340,1115,1197,1234,562,1190,667,1119,1267,2009,1822,1937,1319,261,1295,897,191,1221,1295,589,785,193,1767,1611,663,148,120,1677,1323,1743,1163,485,1939,1209,1736,542,474,649,970,647,938,1117,1749,212,1167,1129,959,636,262,1610,309,1601,370,1052,1026,1156,634,1344,447,1448,1045,1539,1659,726,1626,893,172,1567,1301,11,222,174,1721,1771,929,632,1456,1691,282,1354,1142,1140,1684,780,1436,1519,1941,373,2004,556,1886,26,1289,1676,1187,1685,639,1745,423,1802,1068,122,34,1425,1869,742,1616,236,1498,1706,632,1776,390,633,1717,102,1726,1477,1408,883,65,140,1895,60,789,881,24,1997,1715,1575,1420,145,819,236,271,1599,1913,800,736,1559,973,1374,1861,1522,962,697,425,1620,0,1204,1765,1261,864,1003,1330,1821,589,448,1842,1759,4,749,741,744,506,1706,1152,1746,462,1608,1874,1036,1327,1785,1206,2032,1092,423,11,1559,1013,312,1671,46,1618,537,429,1894,909,1261,1905,397,841,1992,1024,874,878,1903,1948,361,1487,535,1985,438,823,1911,1984,1832,1400,1826,566,488,1664,1170,1156,1959,1972,1557,1158,832,1154,662,37,1198,967,1096,242,1354,642,83,928,1551,108,111,1236,1660,1097,1654,915,822,1731,460,1729,1721,1694,268,1571,1411,334,1150,1577,945,1032,1078,1178,1093,1256,1044,503,43,1775,1203,1656,22,1482,1093,1340,821,477,156,750,1624,1497,1675,1789,1150,456,1682,1105,498,943,94,454,937,1848,1458,1520,74,1407,701,962,1220,862,458,1470,1695,171,561,586,1150,121,705,1681,240,1067,1658,1280,1849,1971,71,1400,715,1260,105,40,1378,685,692,1088,674,1493,525,815,1313,178,1214,1893,1287,758,1200,1657,763,749,1046,82,1677,71,835,1806,679,574,368,1177,1104,610,1203,1902,342,1448,258,1105,1671,1217,1300,259,81,140,1855,1984,1723,1919,1259,1977,1802,1304,1466,1085,1855,1242,847,895,1729,1375,298,1000,353,2006,1227,2000,96,2001,1044,513,1411,1516,890,1568,294,1366,88,1762,131,1328,891,308,752,733,825,1813,282,1953,1206,1228,1849,348,1956,1702,1,974,1829,1107,1166,637,491,646,1683,1097,376,100,1099,1236,1925,1498,315,1999,1187,1209,1004,729,1773,1514,1441,1846,928,856,562,426,863,171,812,160,169,1692,1104,1895,1751,1247,363,13,1076,685,76,1537,1383,1070,1637,574,1980,568,351,73,383,1980,1328,934,1087,1768,702,1909,138,2024,28,241,354,1075,1214,1902,1240,47,2014,490,2046,346,468,933,1291,326,1428,1193,1666,368,438,460,842,1807,1488,1026,1036,2046,1547,677,386,386,113,1182,1336,1586,268,778,547,1932,1857,743,1163,195,1082,155,222,703,786,346,1588,1250,220,327,1547,1389,207,1335,2044,1125,845,126,440,750,1566,1484,969,1083,783,353,1243,516,1039,180,1764,519,751,1950,1094,1070,1886,1465,269,1540,285,1982,1076,570,1268,2026,1020,664,1115,952,1399,592,897,670,698,855,1425,1763,548,1147,1778,693,43,1592,865,804,862,293,1421,1528,171,1623,825,2023,1620,775,1873,1111,783,1025,866,1761,183,873,325,1712,1822,630,1885,541,1345,26,1808,1996,367,728,569,902,868,228,371,1800,1168,30,272,240,1437,880,1319,867,1832,798,949,887,1163,2008,1898,1537,1457,1016,235,770,229,953,1284,1258,625,1947,1168,927,349,1491,1713,1076,248,1729,1667,83,1686,1457,52,363];

</script>

Test runner

Ready to run.

Testing in
TestOps/sec
depth-00
var root = document.querySelector('.depth-0');
for (var i = 0; i < randomness.length; ++i) {
  var replacement = document.createElement('div');
  replacement.textContent = 'r-' + i;
  findAndReplace(root, 0, 2048, randomness[i], replacement);
}
ready
depth-01
var root = document.querySelector('.depth-1');
for (var i = 0; i < randomness.length; ++i) {
  var replacement = document.createElement('div');
  replacement.textContent = 'r-' + i;
  findAndReplace(root, 1, 2048, randomness[i], replacement);
}
ready
depth-02
var root = document.querySelector('.depth-2');
for (var i = 0; i < randomness.length; ++i) {
  var replacement = document.createElement('div');
  replacement.textContent = 'r-' + i;
  findAndReplace(root, 2, 2048, randomness[i], replacement);
}
ready
depth-03
var root = document.querySelector('.depth-3');
for (var i = 0; i < randomness.length; ++i) {
  var replacement = document.createElement('div');
  replacement.textContent = 'r-' + i;
  findAndReplace(root, 3, 2048, randomness[i], replacement);
}
ready
depth-04
var root = document.querySelector('.depth-4');
for (var i = 0; i < randomness.length; ++i) {
  var replacement = document.createElement('div');
  replacement.textContent = 'r-' + i;
  findAndReplace(root, 4, 2048, randomness[i], replacement);
}
ready
depth-05
var root = document.querySelector('.depth-5');
for (var i = 0; i < randomness.length; ++i) {
  var replacement = document.createElement('div');
  replacement.textContent = 'r-' + i;
  findAndReplace(root, 5, 2048, randomness[i], replacement);
}
ready
depth-06
var root = document.querySelector('.depth-6');
for (var i = 0; i < randomness.length; ++i) {
  var replacement = document.createElement('div');
  replacement.textContent = 'r-' + i;
  findAndReplace(root, 6, 2048, randomness[i], replacement);
}
ready
depth-07
var root = document.querySelector('.depth-7');
for (var i = 0; i < randomness.length; ++i) {
  var replacement = document.createElement('div');
  replacement.textContent = 'r-' + i;
  findAndReplace(root, 7, 2048, randomness[i], replacement);
}
ready
depth-08
var root = document.querySelector('.depth-8');
for (var i = 0; i < randomness.length; ++i) {
  var replacement = document.createElement('div');
  replacement.textContent = 'r-' + i;
  findAndReplace(root, 8, 2048, randomness[i], replacement);
}
ready
depth-09
var root = document.querySelector('.depth-9');
for (var i = 0; i < randomness.length; ++i) {
  var replacement = document.createElement('div');
  replacement.textContent = 'r-' + i;
  findAndReplace(root, 9, 2048, randomness[i], replacement);
}
ready
depth-10
var root = document.querySelector('.depth-10');
for (var i = 0; i < randomness.length; ++i) {
  var replacement = document.createElement('div');
  replacement.textContent = 'r-' + i;
  findAndReplace(root, 10, 2048, randomness[i], replacement);
}
ready
depth-11
var root = document.querySelector('.depth-11');
for (var i = 0; i < randomness.length; ++i) {
  var replacement = document.createElement('div');
  replacement.textContent = 'r-' + i;
  findAndReplace(root, 11, 2048, randomness[i], replacement);
}
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.