Skip to content

Commit

Permalink
Merge pull request #446 from MatrixAI/feature-crypto
Browse files Browse the repository at this point in the history
Updating Crypto to use WebCrypto API and to replace RSA with ECC
  • Loading branch information
tegefaulkes authored Dec 8, 2022
2 parents a40378b + c68a01d commit fcc0779
Show file tree
Hide file tree
Showing 406 changed files with 31,058 additions and 15,796 deletions.
45 changes: 25 additions & 20 deletions benches/index.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,39 @@
#!/usr/bin/env ts-node

import type { Summary } from 'benny/lib/internal/common-types';
import fs from 'fs';
import path from 'path';
import si from 'systeminformation';
import gitgc from './gitgc';
import { fsWalk, resultsPath, suitesPath } from './utils';

async function main(): Promise<void> {
await fs.promises.mkdir(path.join(__dirname, 'results'), { recursive: true });
await gitgc();
const resultFilenames = await fs.promises.readdir(
path.join(__dirname, 'results'),
);
const metricsFile = await fs.promises.open(
path.join(__dirname, 'results', 'metrics.txt'),
'w',
);
// Running all suites
for await (const suitePath of fsWalk(suitesPath)) {
// Skip over non-ts and non-js files
const ext = path.extname(suitePath);
if (ext !== '.ts' && ext !== '.js') {
continue;
}
const suite: () => Promise<Summary> = (await import(suitePath)).default;
await suite();
}
// Concatenating metrics
const metricsPath = path.join(resultsPath, 'metrics.txt');
await fs.promises.rm(metricsPath);
let concatenating = false;
for (const resultFilename of resultFilenames) {
if (/.+_metrics\.txt$/.test(resultFilename)) {
const metricsData = await fs.promises.readFile(
path.join(__dirname, 'results', resultFilename),
);
if (concatenating) {
await metricsFile.write('\n');
}
await metricsFile.write(metricsData);
concatenating = true;
for await (const metricPath of fsWalk(resultsPath)) {
// Skip over non-metrics files
if (!metricPath.endsWith('_metrics.txt')) {
continue;
}
const metricData = await fs.promises.readFile(metricPath);
if (concatenating) {
await fs.promises.appendFile(metricsPath, '\n');
}
await fs.promises.appendFile(metricsPath, metricData);
concatenating = true;
}
await metricsFile.close();
const systemData = await si.get({
cpu: '*',
osInfo: 'platform, distro, release, kernel, arch',
Expand Down
116 changes: 116 additions & 0 deletions benches/results/basic/buffer_encoding_decoding.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>basic.buffer_encoding_decoding</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="chart1666662556031" 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 ctx1666662556031 = document
.getElementById('chart1666662556031')
.getContext('2d')
const chart1666662556031 = new Chart(ctx1666662556031, {
type: 'bar',
data: {
labels: ["JSON stringify and parse buffer","Base64 encode and decode buffer","Base64url encode and decode buffer"],
datasets: [
{
data: [172634,1385074,1327362],
backgroundColor: ["hsl(14.951999999999991, 85%, 55%)","hsl(120, 85%, 55%)","hsl(114.996, 85%, 55%)"],
borderColor: ["hsl(14.951999999999991, 85%, 55%)","hsl(120, 85%, 55%)","hsl(114.996, 85%, 55%)"],
borderWidth: 2,
},
],
},
options: {
maintainAspectRatio: false,
plugins: {
title: {
display: true,
text: 'basic.buffer_encoding_decoding',
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 fcc0779

Please sign in to comment.