Skip to content

Latest commit

 

History

History
95 lines (95 loc) · 3.68 KB

batchanalysis.md

File metadata and controls

95 lines (95 loc) · 3.68 KB
title subtitle layout show_sidebar
Batch Analysis
Analysis to the sorts -- One list
page
false
<style> .scrollable-list { max-height: 100px; /* Adjust the max height as needed */ overflow-y: auto; } </style> <script> function sendSortRequest(sortType) { var data = document.getElementById(sortType + 'Input').value; var requestData = data.split(',').map(Number); fetch('https://ww3.stu.nighthawkcodingsociety.com/api/sorting/' + sortType, { method: 'POST', body: JSON.stringify(requestData), headers: { 'Content-Type': 'application/json', }, }) .then(response => response.json()) .then(data => { // Update the table with the results document.getElementById(sortType + 'List').textContent = data.sortedList.join(', '); document.getElementById(sortType + 'Time').textContent = data.timeTakenMs; document.getElementById(sortType + 'Iterations').textContent = data.iterations; document.getElementById(sortType + 'Comparisons').textContent = data.comparisons; document.getElementById(sortType + 'Swaps').textContent = data.swaps; }) .catch((error) => { console.error('Error:', error); }); } function analyzeSorts() { var data = document.getElementById('analysisInput').value; var requestData = data.split(',').map(Number); fetch('http://localhost:8062/api/sorting/analyze', { method: 'POST', body: JSON.stringify(requestData), headers: { 'Content-Type': 'application/json', }, }) .then(response => response.json()) .then(data => { // Clear any previous analysis results document.getElementById('analysisTable').innerHTML = ''; // Create a new table to display analysis results var table = document.createElement('table'); table.innerHTML = ` Sort Type Sorted List Time Taken (ms) Iterations Comparisons Swaps `; var tableBody = table.querySelector('#analysisTableBody'); // Iterate through the analysis results and add rows to the table data.forEach(result => { var row = document.createElement('tr'); row.innerHTML = ` ${result.sortType}
${result.sortedList.join(', ')}
${result.timeTakenMs} ${result.iterations} ${result.comparisons} ${result.swaps} `; tableBody.appendChild(row); }); // Append the table to the analysisResult div document.getElementById('analysisTable').appendChild(table); }) .catch((error) => { console.error('Error:', error); }); } </script>

Sorting Analysis

Analyze