HTML Preparation code:
AخA
 
1
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js" integrity="sha512-894YE6QWD5I59HgZOGReFYm4dnWc1Qt5NtvYSaNcOP+u1T9qYdvdihz0PPSiiqn/+/3e7Jo4EaG7TubfWGUrMQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
2
<table id='testTable'>
3
    <tbody>
4
        <tr id='countRow'>
5
            <td class='count'>0</td>
6
        </tr>
7
    </tbody>
8
</table>
Script Preparation code:
x
 
var $testTable = $("#testTable");
var count = 0;
function updateWhole() {
    $testTable.html("<tbody><tr id='countRow'><td class='count'>" + count + "h</td></tr></tbody>");
}
function updateCell() {
    var $elem = $("#countRow .count");
    var cnt = parseInt($elem.text() || 0);
    $elem.text(++cnt);
}
Tests:
  • Take count from element and update

     
    updateCell();
  • Update whole table

     
    count++;
    updateWhole();
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Take count from element and update
    Update whole table

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 3 years ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36
Chrome 95 on Windows
View result in a separate tab
Test name Executions per second
Take count from element and update 104890.6 Ops/sec
Update whole table 29820.3 Ops/sec