Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add more benchmarks #1

Merged
merged 2 commits into from
Jul 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 116 additions & 0 deletions benchmark/results/2023-07-13T11:29:47.824Z.chart.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" />
<script src="https://cdn.jsdelivr.net/npm/chart.js@3.5.1/dist/chart.min.js"></script>
<title>ts-pattern-benchmark</title>
<style>
body {
margin: 0;
padding: 0;
background: #ddd;
}

.container {
box-sizing: border-box;
height: 96vh;
width: 96vw;
margin: 2vh 2vw;
resize: both;
overflow: hidden;
padding: 20px;
background: white;
box-shadow: 0 0 15px #aaa;
}
</style>
</head>
<body>
<div class="container">
<canvas id="chart1689247787824" width="16" height="9"></canvas>
</div>
<script>
const format = (num) => {
const [whole, fraction] = String(num).split('.')
const chunked = []
whole
.split('')
.reverse()
.forEach((char, index) => {
if (index % 3 === 0) {
chunked.unshift([char])
} else {
chunked[0].unshift(char)
}
})

const fractionStr = fraction !== undefined ? '.' + fraction : ''

return (
chunked.map((chunk) => chunk.join('')).join(' ') + fractionStr
)
}
const ctx1689247787824 = document
.getElementById('chart1689247787824')
.getContext('2d')
const chart1689247787824 = new Chart(ctx1689247787824, {
type: 'bar',
data: {
labels: [".exhaustive()",".otherwise()",".run()","if/else","switch","ternary"],
datasets: [
{
data: [2067911,2126161,2102832,1034366444,1031681437,1033792376],
backgroundColor: ["hsl(0.24000000000000338, 85%, 55%)","hsl(0.2519999999999925, 85%, 55%)","hsl(0.24000000000000338, 85%, 55%)","hsl(120, 85%, 55%)","hsl(119.68799999999999, 85%, 55%)","hsl(119.928, 85%, 55%)"],
borderColor: ["hsl(0.24000000000000338, 85%, 55%)","hsl(0.2519999999999925, 85%, 55%)","hsl(0.24000000000000338, 85%, 55%)","hsl(120, 85%, 55%)","hsl(119.68799999999999, 85%, 55%)","hsl(119.928, 85%, 55%)"],
borderWidth: 2,
},
],
},
options: {
maintainAspectRatio: false,
plugins: {
title: {
display: true,
text: 'ts-pattern-benchmark',
font: { size: 20 },
padding: 20,
},
legend: {
display: false,
},
tooltip: {
callbacks: {
label: (context) => {
return format(context.parsed.y) + ' ops/s'
},
},
displayColors: false,
backgroundColor: '#222222',
padding: 10,
cornerRadius: 5,
intersect: false,
},
},
scales: {
x: {
grid: {
color: '#888888',
},
},
y: {
title: {
display: true,
text: 'Operations per second',
padding: 10,
},
grid: {
color: '#888888',
},
},
},
},
})
</script>
</body>
</html>
51 changes: 51 additions & 0 deletions benchmark/results/2023-07-13T11:29:47.824Z.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"name": "ts-pattern-benchmark",
"date": "2023-07-13T11:29:47.824Z",
"version": null,
"results": [
{
"name": ".exhaustive()",
"ops": 2067911,
"margin": 0.48,
"percentSlower": 99.8
},
{
"name": ".otherwise()",
"ops": 2126161,
"margin": 0.13,
"percentSlower": 99.79
},
{
"name": ".run()",
"ops": 2102832,
"margin": 0.15,
"percentSlower": 99.8
},
{
"name": "if/else",
"ops": 1034366444,
"margin": 0.07,
"percentSlower": 0
},
{
"name": "switch",
"ops": 1031681437,
"margin": 0.17,
"percentSlower": 0.26
},
{
"name": "ternary",
"ops": 1033792376,
"margin": 0.1,
"percentSlower": 0.06
}
],
"fastest": {
"name": "if/else",
"index": 3
},
"slowest": {
"name": ".exhaustive()",
"index": 0
}
}
33 changes: 33 additions & 0 deletions benchmark/results/2023-07-13T11:29:47.824Z.table.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" />
<title>ts-pattern-benchmark</title>
</head>
<body>
<table>
<thead>
<tr>
<th>name</th><th>ops</th><th>margin</th><th>percentSlower</th>
</tr>
</thead>
<tbody>
<tr>
<td>.exhaustive()</td><td>2067911</td><td>0.48</td><td>99.8</td>
</tr><tr>
<td>.otherwise()</td><td>2126161</td><td>0.13</td><td>99.79</td>
</tr><tr>
<td>.run()</td><td>2102832</td><td>0.15</td><td>99.8</td>
</tr><tr>
<td>if/else</td><td>1034366444</td><td>0.07</td><td>0</td>
</tr><tr>
<td>switch</td><td>1031681437</td><td>0.17</td><td>0.26</td>
</tr><tr>
<td>ternary</td><td>1033792376</td><td>0.1</td><td>0.06</td>
</tr>
</tbody>
</table>
</body>
</html>
116 changes: 116 additions & 0 deletions benchmark/results/2023-07-13T11:32:17.477Z.chart.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" />
<script src="https://cdn.jsdelivr.net/npm/chart.js@3.5.1/dist/chart.min.js"></script>
<title>ts-pattern-benchmark</title>
<style>
body {
margin: 0;
padding: 0;
background: #ddd;
}

.container {
box-sizing: border-box;
height: 96vh;
width: 96vw;
margin: 2vh 2vw;
resize: both;
overflow: hidden;
padding: 20px;
background: white;
box-shadow: 0 0 15px #aaa;
}
</style>
</head>
<body>
<div class="container">
<canvas id="chart1689247937477" width="16" height="9"></canvas>
</div>
<script>
const format = (num) => {
const [whole, fraction] = String(num).split('.')
const chunked = []
whole
.split('')
.reverse()
.forEach((char, index) => {
if (index % 3 === 0) {
chunked.unshift([char])
} else {
chunked[0].unshift(char)
}
})

const fractionStr = fraction !== undefined ? '.' + fraction : ''

return (
chunked.map((chunk) => chunk.join('')).join(' ') + fractionStr
)
}
const ctx1689247937477 = document
.getElementById('chart1689247937477')
.getContext('2d')
const chart1689247937477 = new Chart(ctx1689247937477, {
type: 'bar',
data: {
labels: [".exhaustive()",".otherwise()",".run()","if/else","switch","ternary"],
datasets: [
{
data: [2349006,2342324,2327898,49697711,50302329,50145325],
backgroundColor: ["hsl(5.604000000000003, 85%, 55%)","hsl(5.591999999999996, 85%, 55%)","hsl(5.555999999999994, 85%, 55%)","hsl(118.56, 85%, 55%)","hsl(120, 85%, 55%)","hsl(119.628, 85%, 55%)"],
borderColor: ["hsl(5.604000000000003, 85%, 55%)","hsl(5.591999999999996, 85%, 55%)","hsl(5.555999999999994, 85%, 55%)","hsl(118.56, 85%, 55%)","hsl(120, 85%, 55%)","hsl(119.628, 85%, 55%)"],
borderWidth: 2,
},
],
},
options: {
maintainAspectRatio: false,
plugins: {
title: {
display: true,
text: 'ts-pattern-benchmark',
font: { size: 20 },
padding: 20,
},
legend: {
display: false,
},
tooltip: {
callbacks: {
label: (context) => {
return format(context.parsed.y) + ' ops/s'
},
},
displayColors: false,
backgroundColor: '#222222',
padding: 10,
cornerRadius: 5,
intersect: false,
},
},
scales: {
x: {
grid: {
color: '#888888',
},
},
y: {
title: {
display: true,
text: 'Operations per second',
padding: 10,
},
grid: {
color: '#888888',
},
},
},
},
})
</script>
</body>
</html>
51 changes: 51 additions & 0 deletions benchmark/results/2023-07-13T11:32:17.477Z.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"name": "ts-pattern-benchmark",
"date": "2023-07-13T11:32:17.477Z",
"version": null,
"results": [
{
"name": ".exhaustive()",
"ops": 2349006,
"margin": 0.13,
"percentSlower": 95.33
},
{
"name": ".otherwise()",
"ops": 2342324,
"margin": 0.1,
"percentSlower": 95.34
},
{
"name": ".run()",
"ops": 2327898,
"margin": 0.1,
"percentSlower": 95.37
},
{
"name": "if/else",
"ops": 49697711,
"margin": 0.09,
"percentSlower": 1.2
},
{
"name": "switch",
"ops": 50302329,
"margin": 0.08,
"percentSlower": 0
},
{
"name": "ternary",
"ops": 50145325,
"margin": 0.27,
"percentSlower": 0.31
}
],
"fastest": {
"name": "switch",
"index": 4
},
"slowest": {
"name": ".run()",
"index": 2
}
}
Loading