File: benchmarks.html

package info (click to toggle)
bpfilter 0.5.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,076 kB
  • sloc: ansic: 30,397; sh: 1,383; cpp: 959; python: 495; yacc: 385; lex: 194; makefile: 9
file content (246 lines) | stat: -rw-r--r-- 9,913 bytes parent folder | download
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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <title>bpfilter benchmarks</title>
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
    <script>
        window.addEventListener('load', function () {
            render();
        })

        const data = {"commits": [], "results": {}, "benchNames": []}

        function render() {
            for (const benchName of data.benchNames) {
                makeTable(benchName, data.commits, data.results[benchName])
                makeChart(benchName, data.commits, data.results[benchName])
            }

        }

        function makeTable(name, commits, results) {

            const newCommit = commits[commits.length - 1];
            const newResults = results[newCommit.sha];
            const newTime = newResults.time;
            const newInsns = newResults.nInsn;

            let newHtml = `<td class="text-end font-monospace">${parseFloat(newResults.time).toFixed(2)}</td>`;
            newHtml += `<td class="text-end font-monospace">${newResults.nInsn}</td>`;

            let diffHtml = '';
            let oldHtml = '';

            if (commits.length > 1) {
                // There is a second to last commit
                const oldCommit = commits.length > 1 ? commits[commits.length - 2] : null;
                const oldResults = results[oldCommit.sha];

                const oldTime = oldResults.time;
                const oldInsns = oldResults.nInsn;
                const absTime = newTime - oldTime;
                const absInsns = newInsns - oldInsns;
                const diffTime = (absTime / oldTime) * 100;
                const diffInsns = (absInsns / oldInsns) * 100;

                const timeDiffClass = diffTime > 0 ? "text-danger" : "text-success";
                const nInsnsDiffClass = diffInsns > 0 ? "text-danger" : "text-success";
                diffHtml += `<td class="text-end font-monospace ${timeDiffClass}">${(diffTime < 0 ? "" : "+") + parseFloat(diffTime).toFixed(2)}% (${(absTime < 0 ? "" : "+") + parseFloat(absTime).toFixed(2)})</td>`;
                diffHtml += `<td class="text-end font-monospace ${nInsnsDiffClass}">${(diffInsns < 0 ? "" : "+") + parseFloat(diffInsns).toFixed(2)}% (${(absInsns < 0 ? "" : "+") + parseFloat(absInsns)})</td>`;

                oldHtml += `<td class="text-end font-monospace">${parseFloat(oldResults.time).toFixed(2)}</td>`;
                oldHtml += `<td class="text-end font-monospace">${oldResults.nInsn}</td>`;
            } else {
                diffHtml += '<td class="text-end font-monospace">n/a</td><td class="font-monospace">n/a</td>';
                oldHtml += '<td class="text-end font-monospace">n/a</td><td class="font-monospace">n/a</td>';
            }


            let data = '<tr>';
            data += `<td>${name}</td>`;
            data += diffHtml;
            data += newHtml;
            data += oldHtml;
            data += '</tr>';

            const table = document.getElementById('table-body');
            table.insertAdjacentHTML("beforeend", data);
        }

        function makeChart(name, commits, results) {
            const ctx = document.getElementById('charts');
            ctx.insertAdjacentHTML("beforeend",
                `<div class="col container-fluid my-3" id="${name}"><h5>${name}</h5></div>`
            );

            const chartCtx = document.getElementById(name);
            chartCtx.insertAdjacentHTML("beforeend",
                `<canvas id="${name}Chart"></canvas>`
            );

            var durations = []
            var nInsns = []
            var labels = []
            for (commit of commits) {
                const result = results[commit.sha]
                if (result == undefined) {
                    durations.push(null);
                    nInsns.push(null);
                } else {
                    durations.push(result.time);
                    nInsns.push(result.nInsn);
                }

                labels.push(commit.sha);
            }

            const afterTitle = (tooltipItems) => {
                const commit = commits.find((e) => e.sha == tooltipItems[0].label);
                return commit.message;
            };

            new Chart(document.getElementById(name + "Chart"), {
                type: 'line',
                data: {
                    labels: labels,
                    datasets: [
                        {
                            label: 'Duration',
                            data: durations,
                            yAxisID: 'duration',
                            tension: 0.1,
                            fill: true,
                            order: 2,
                        },
                        {
                            label: '# of instructions',
                            data: nInsns,
                            yAxisID: 'instructions',
                            tension: 0.1,
                            order: 1,
                        }
                    ]
                },
                options: {
                    interaction: {
                        intersect: false,
                        mode: 'index',
                    },
                    plugins: {

                        tooltip: {
                            callbacks: {
                                afterTitle: afterTitle,
                                label: function (context) {
                                    let label = '';

                                    if (context.dataset.yAxisID == "duration")
                                        label = parseFloat(context.parsed.y).toFixed(2) + " ns"
                                    else if (context.dataset.yAxisID == "instructions")
                                        label = parseInt(context.parsed.y) + " instructions"
                                    else
                                        label = context.parsed.y;

                                    return label;
                                }
                            }
                        }
                    },
                    scales: {
                        duration: {
                            id: 't (ns)',
                            type: 'linear',
                            position: 'left',
                            min: 0,
                            title: {
                                display: true,
                                text: 'ns'
                            },
                        },
                        instructions: {
                            id: '# insn',
                            type: 'linear',
                            position: 'right',
                            min: 0,
                            title: {
                                display: true,
                                text: '# insn'
                            },
                        },
                        x: {
                            title: {
                                display: true,
                                text: 'Commit'
                            },
                        }
                    },
                    onClick: function (e) {
                        const sha = e.chart.tooltip.dataPoints[0].label
                        if (sha.endsWith("+"))
                            return;
                        window.open("https://github.com/facebook/bpfilter/commit/" + sha, "_blank");
                    }
                }
            });
        }
    </script>
</head>

<body>
    <nav class="navbar bg-body-tertiary">
        <div class="container-fluid">
            <a class="navbar-brand" href="#">
                <picture>
                    <source srcset="./logo-dark-mode.png" media="(prefers-color-scheme: dark)">
                    <img src="./logo-light-mode.png"  height="30" class="d-inline-block align-top" alt="">
                </picture>
                bpfilter benchmark
            </a>
        </div>
    </nav>
    <div class="jumbotron m-5 p-5 bg-light">
        <div class="container">
            <h2>Last results</h2>
            <p class="lead">Performance of the last commit, compared to the second to last.</p>
        </div>
        <table class="table">
            <thead>
                <tr>
                    <th scope="col" rowspan="2">Benchmark</th>
                    <th scope="col" colspan="2" class="text-end">Diff</th>
                    <th scope="col" colspan="2" class="text-end">New</th>
                    <th scope="col" colspan="2" class="text-end">Old</th>
                </tr>
                <tr>
                    <th scope="col" class="text-end">Runtime</th>
                    <th scope="col" class="text-end">Instructions</th>
                    <th scope="col" class="text-end">Runtime</th>
                    <th scope="col" class="text-end">Instructions</th>
                    <th scope="col" class="text-end">Runtime</th>
                    <th scope="col" class="text-end">Instructions</th>
                </tr>
            </thead>
            <tbody id="table-body">
            </tbody>
        </table>
    </div>

    <div class="jumbotron m-5 p-5 bg-light">
        <div class="container">
            <h2>Results over time</h2>
            <p class="lead">Evolution of the benchmark results over time.</p>
        </div>
        <div class="container-fluid">
            <div class="row row-cols-2" id="charts">
            </div>
        </div>
    </div>
</body>

</html>