Skip to content

Commit

Permalink
Add benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
lxsmnsyc committed Mar 16, 2023
1 parent a3cfb8e commit 9eefa7a
Show file tree
Hide file tree
Showing 75 changed files with 28,780 additions and 143 deletions.
23 changes: 23 additions & 0 deletions benchmark/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module.exports = {
"root": true,
"extends": [
'lxsmnsyc/typescript',
],
"parserOptions": {
"project": "./tsconfig.eslint.json",
"tsconfigRootDir": __dirname,
},
"rules": {
"import/no-extraneous-dependencies": [
"error", {
"devDependencies": ["**/*.test.ts"]
}
],
"no-plusplus": "off",
"no-continue": "off",
"no-param-reassign": "off",
"no-restricted-syntax": "off",
"no-bitwise": "off",
"prefer-template": "off"
}
};
110 changes: 110 additions & 0 deletions benchmark/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.production
.env.development

# parcel-bundler cache (https://parceljs.org/)
.cache

# Next.js build output
.next

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

.npmrc


build
7 changes: 7 additions & 0 deletions benchmark/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
MIT License Copyright (c) 2023 Alexis Munsayac <alexis.munsayac@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Empty file added benchmark/README.md
Empty file.
19 changes: 19 additions & 0 deletions benchmark/build-src.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import * as esbuild from 'esbuild';

esbuild.buildSync({
entryPoints: [
'./src/index.ts',
],
outfile: './build/index.cjs',
bundle: true,
minify: true,
sourcemap: false,
format: 'cjs',
platform: 'node',
tsconfig: './tsconfig.json',
target: "es2018",
legalComments: 'eof',
external: [
"benny",
],
});
46 changes: 46 additions & 0 deletions benchmark/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"name": "seroval-benchmarks",
"type": "module",
"private": true,
"scripts": {
"build": "node build-src",
"start": "node build-src && node build/index.cjs"
},
"devDependencies": {
"@types/node": "^18.15.3",
"esbuild": "^0.17.11",
"eslint": "^8.36.0",
"eslint-config-lxsmnsyc": "^0.5.1",
"tslib": "^2.4.1",
"typescript": "^4.9.5"
},
"dependencies": {
"benny": "^3.7.1",
"devalue": "^4.3.0",
"flatted": "^3.2.7",
"next-json": "^0.2.2",
"o-son": "^1.0.1",
"serialize-javascript": "^6.0.1",
"seroval": "workspace:^0.4.1",
"superjson": "^1.12.2",
"tosource": "2.0.0-alpha.3",
"warp10": "^2.1.0"
},
"types": "./dist/types/index.d.ts",
"main": "./dist/cjs/production/index.cjs",
"module": "./dist/esm/production/index.mjs",
"exports": {
".": {
"development": {
"require": "./dist/cjs/development/index.cjs",
"import": "./dist/esm/development/index.mjs"
},
"require": "./dist/cjs/production/index.cjs",
"import": "./dist/esm/production/index.mjs",
"types": "./dist/types/index.d.ts"
}
},
"typesVersions": {
"*": {}
}
}
3 changes: 3 additions & 0 deletions benchmark/pridepack.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"target": "es2017"
}
116 changes: 116 additions & 0 deletions benchmark/results/charts/circular-dedupe to string.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>circular-dedupe to string</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="chart1678980264846" 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 ctx1678980264846 = document
.getElementById('chart1678980264846')
.getContext('2d')
const chart1678980264846 = new Chart(ctx1678980264846, {
type: 'bar',
data: {
labels: ["devalue","flatted","next-json","o-son","seroval","superjson","warp10"],
datasets: [
{
data: [66826,51078,56602,101714,111032,6548,115778],
backgroundColor: ["hsl(69.264, 85%, 55%)","hsl(52.943999999999996, 85%, 55%)","hsl(58.668, 85%, 55%)","hsl(105.41999999999999, 85%, 55%)","hsl(115.08000000000001, 85%, 55%)","hsl(6.791999999999995, 85%, 55%)","hsl(120, 85%, 55%)"],
borderColor: ["hsl(69.264, 85%, 55%)","hsl(52.943999999999996, 85%, 55%)","hsl(58.668, 85%, 55%)","hsl(105.41999999999999, 85%, 55%)","hsl(115.08000000000001, 85%, 55%)","hsl(6.791999999999995, 85%, 55%)","hsl(120, 85%, 55%)"],
borderWidth: 2,
},
],
},
options: {
maintainAspectRatio: false,
plugins: {
title: {
display: true,
text: 'circular-dedupe to string',
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>
Loading

0 comments on commit 9eefa7a

Please sign in to comment.