Skip to content

Commit

Permalink
Add stats at the bottom of the table
Browse files Browse the repository at this point in the history
  • Loading branch information
mebeim committed Mar 20, 2024
1 parent 29aba65 commit 4811fcb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ <h3>
<th class="sortable" title="Click to sort">Kconfig</th>
</tr>
</table>
<h3 id="summary"></h3>
</section>
<p>Copyright &copy; 2023-2024 Marco Bonelli &mdash; Licensed under the GNU General Public License v3.0</p>
<script src="./stats.js"></script>
Expand Down
16 changes: 15 additions & 1 deletion www/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict'

const tableEl = document.getElementsByTagName('table')[0]
const sumamryEl = document.getElementById('summary')
const themeToggleEl = document.getElementById('theme-toggle')
const compactSigToggleEl = document.getElementById('compact-sig-toggle')
const tagSelectEl = document.getElementById('tag-select')
Expand Down Expand Up @@ -412,7 +413,7 @@ function fillRow(row, tag, sc, maxArgs) {
function fillTable(syscallTable, tag) {
const numReg = syscallTable.kernel.abi.calling_convention.syscall_nr
const argRegs = syscallTable.kernel.abi.calling_convention.parameters
const maxArgs = Math.max(...syscallTable.syscalls.map(sc => sc.signature?.length || 0))
const maxArgs = syscallTable.syscalls.reduce((acc, sc) => Math.max(acc, sc.signature?.length || 0), 0)
const [header1, header2] = tableEl.querySelectorAll('tr')

compactSigToggleEl.textContent = compactSignature ? 'expand' : 'collapse'
Expand Down Expand Up @@ -476,6 +477,19 @@ async function update(pushHistoryState) {
currentSyscallTable = await fetchSyscallTable(arch, bits, abi, tag)
fillTable(currentSyscallTable, tag)

// Some stats at the bottom of the table
const n_syscalls = currentSyscallTable.syscalls.length
const n_esoteric = currentSyscallTable.syscalls.reduce((acc, sc) => acc + sc.esoteric, 0)
const n_bad_loc = currentSyscallTable.syscalls.reduce((acc, sc) => acc + !sc.good_location, 0)
const n_no_loc = currentSyscallTable.syscalls.reduce((acc, sc) => acc + (sc.file === null), 0)
const n_no_sig = currentSyscallTable.syscalls.reduce((acc, sc) => acc + (sc.signature === null), 0)

sumamryEl.textContent = `${n_syscalls} syscalls`
if (n_esoteric) sumamryEl.textContent += ` (${n_esoteric} esoteric)`
if (n_bad_loc) sumamryEl.textContent += `, ${n_bad_loc} non-standard definitions`
if (n_no_loc) sumamryEl.textContent += `, ${n_no_loc} missing location info`
if (n_no_sig) sumamryEl.textContent += `, ${n_no_sig} missing signature info`

systrackVersEl.textContent = currentSyscallTable.systrack_version
jsonLinkEl.href = `db/${arch}/${bits}/${abi}/${tag}/table.json`

Expand Down

0 comments on commit 4811fcb

Please sign in to comment.