-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
225 lines (196 loc) · 6.55 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdnjs.cloudflare.com/ajax/libs/PapaParse/5.3.0/papaparse.min.js"></script>
<style>
body {
font-family: Arial, sans-serif;
text-align: center;
margin: 0;
}
h1 {
margin: 20px;
}
#commit-hash {
margin: 10px;
}
table {
width: 80%;
margin: 20px auto;
border-collapse: collapse;
}
th,
td {
border: 1px solid #ccc;
padding: 8px;
text-align: left;
}
th {
background-color: #f4f4f4;
}
/* Zebra stripe alternate rows */
tr:nth-child(even) {
background-color: #f9f9f9;
}
/* Highlight row on hover */
tr:hover {
background-color: #e6e6e6;
}
</style>
<title>RISC Zero Benchmarks</title>
</head>
<body>
<h1>RISC Zero Benchmarks</h1>
<p id="commit-hash">Commit hash: <span id="hash-content">Loading...</span>
<br></br>
Use <i>RUST_LOG=info cargo run --release -- --out metrics.csv all</i> from the benchmarks folder to collect data for
your
machine
</p>
<table id="comparison-table"></table>
<script>
// Array of CSV file URLs
const csvFiles = ['macOS-cpu.average.csv', 'Linux-cpu.average.csv', 'macOS-apple_m2_pro.average.csv', 'Linux-nvidia_rtx_a5000.average.csv', 'Bonsai.average.csv'];
// Object to hold combined data
const combinedData = {};
const processFile = (fileUrl, index) => {
return new Promise((resolve) => {
Papa.parse(fileUrl, {
download: true,
header: true,
complete: (results) => {
results.data.forEach(row => {
if (!combinedData[row.job_name]) {
combinedData[row.job_name] = [];
}
combinedData[row.job_name][index] = row.ops_sec;
});
resolve();
}
});
});
};
Promise.all(csvFiles.map((fileUrl, index) => processFile(fileUrl, index)))
.then(() => {
displayTable();
})
.catch(error => {
console.error('Error processing files:', error);
});
// Function to display the combined table
const displayTable = () => {
const table = document.getElementById('comparison-table');
// Add header row
let headerRow = '<tr><th>Job Name</th>';
csvFiles.forEach((fileUrl, index) => {
const fileName = fileUrl.split('/').pop().split('.')[0];
headerRow += `<th>Ops/Sec (${fileName})</th>`;
});
headerRow += '</tr>';
table.innerHTML = headerRow;
// Add data rows
for (const jobName in combinedData) {
if (!jobName) continue; // Skip if jobName is empty or undefined
let dataRow = `<tr><td>${jobName}</td>`;
combinedData[jobName].forEach(opsSec => {
dataRow += `<td>${parseFloat(opsSec).toFixed(2)}</td>`;
});
dataRow += '</tr>';
table.insertAdjacentHTML('beforeend', dataRow);
}
};
// Function to format duration
function formatDuration(duration) {
const thresholds = [1000, 1000, 1000, 60, 60];
const units = ['ns', 'µs', 'ms', 's', 'min', 'h'];
let unitIndex = 0;
while (duration >= thresholds[unitIndex] && unitIndex < thresholds.length) {
duration /= thresholds[unitIndex];
unitIndex++;
}
return `${duration.toFixed(2)}${units[unitIndex]}`;
}
// Function to format bytes
function formatBytes(bytes) {
const units = ['B', 'KB', 'MB', 'GB', 'TB'];
let unitIndex = 0;
while (bytes >= 1024 && unitIndex < units.length - 1) {
bytes /= 1024;
unitIndex++;
}
return `${bytes.toFixed(2)}${units[unitIndex]}`;
}
// Function to fetch and display commit hash
async function fetchCommitHash() {
try {
let response = await fetch('COMMIT_HASH.txt');
let data = await response.text();
if (!data.includes('This page could not be found')) {
document.getElementById('hash-content').textContent = data;
}
} catch (error) {
console.error('Error fetching commit hash:', error);
}
}
// Function to fetch and display CSV data
async function fetchCSV() {
const filenameToTitle = {
'macOS-apple_m2_pro.csv': 'Metal on Apple M2 Pro',
'Linux-nvidia_rtx_a5000.csv': 'CUDA on NVIDIA RTX A5000',
'macOS-cpu.csv': 'CPU only on Apple M2 Pro',
'Linux-cpu.csv': 'CPU only on TBD [Linux]'
};
const urls = ['macOS-apple_m2_pro.csv', 'Linux-nvidia_rtx_a5000.csv', 'macOS-cpu.csv', 'Linux-cpu.csv'];
for (let url of urls) {
try {
let response = await fetch(url);
// Check if the response status is okay
if (!response.ok) {
console.error(`Failed to fetch ${url}: ${response.statusText}`);
continue; // skip to the next URL
}
let data = await response.text();
let rows = data.split('\n').filter(row => row.trim().length > 0); // Filter out empty rows
// Create a table title using h2
let titleElement = document.createElement('h2');
titleElement.textContent = filenameToTitle[url];
document.body.appendChild(titleElement);
let table = document.createElement('table');
rows.forEach((row, rowIndex) => {
let tr = document.createElement('tr');
let cells = row.split(',');
cells.forEach((cell, index) => {
let cellElement;
if (rowIndex === 0) {
cellElement = document.createElement('th');
} else {
cellElement = document.createElement('td');
}
if (rowIndex !== 0) {
if (index === 2 || index === 3 || index === 4 || index === 5) {
cellElement.textContent = formatDuration(Number(cell));
} else if (index === 8) {
cellElement.textContent = formatBytes(Number(cell));
} else {
cellElement.textContent = cell;
}
} else {
cellElement.textContent = cell;
}
tr.appendChild(cellElement);
});
table.appendChild(tr);
});
document.body.appendChild(table);
} catch (error) {
console.error(`Error fetching CSV data from ${url}:`, error);
}
}
}
fetchCommitHash();
fetchCSV();
</script>
</body>
</html>