Skip to content

Commit fcc0779

Browse files
authored
Merge pull request #446 from MatrixAI/feature-crypto
Updating Crypto to use WebCrypto API and to replace RSA with ECC
2 parents a40378b + c68a01d commit fcc0779

File tree

406 files changed

+31058
-15796
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

406 files changed

+31058
-15796
lines changed

benches/index.ts

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,39 @@
11
#!/usr/bin/env ts-node
22

3+
import type { Summary } from 'benny/lib/internal/common-types';
34
import fs from 'fs';
45
import path from 'path';
56
import si from 'systeminformation';
6-
import gitgc from './gitgc';
7+
import { fsWalk, resultsPath, suitesPath } from './utils';
78

89
async function main(): Promise<void> {
910
await fs.promises.mkdir(path.join(__dirname, 'results'), { recursive: true });
10-
await gitgc();
11-
const resultFilenames = await fs.promises.readdir(
12-
path.join(__dirname, 'results'),
13-
);
14-
const metricsFile = await fs.promises.open(
15-
path.join(__dirname, 'results', 'metrics.txt'),
16-
'w',
17-
);
11+
// Running all suites
12+
for await (const suitePath of fsWalk(suitesPath)) {
13+
// Skip over non-ts and non-js files
14+
const ext = path.extname(suitePath);
15+
if (ext !== '.ts' && ext !== '.js') {
16+
continue;
17+
}
18+
const suite: () => Promise<Summary> = (await import(suitePath)).default;
19+
await suite();
20+
}
21+
// Concatenating metrics
22+
const metricsPath = path.join(resultsPath, 'metrics.txt');
23+
await fs.promises.rm(metricsPath);
1824
let concatenating = false;
19-
for (const resultFilename of resultFilenames) {
20-
if (/.+_metrics\.txt$/.test(resultFilename)) {
21-
const metricsData = await fs.promises.readFile(
22-
path.join(__dirname, 'results', resultFilename),
23-
);
24-
if (concatenating) {
25-
await metricsFile.write('\n');
26-
}
27-
await metricsFile.write(metricsData);
28-
concatenating = true;
25+
for await (const metricPath of fsWalk(resultsPath)) {
26+
// Skip over non-metrics files
27+
if (!metricPath.endsWith('_metrics.txt')) {
28+
continue;
29+
}
30+
const metricData = await fs.promises.readFile(metricPath);
31+
if (concatenating) {
32+
await fs.promises.appendFile(metricsPath, '\n');
2933
}
34+
await fs.promises.appendFile(metricsPath, metricData);
35+
concatenating = true;
3036
}
31-
await metricsFile.close();
3237
const systemData = await si.get({
3338
cpu: '*',
3439
osInfo: 'platform, distro, release, kernel, arch',
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<meta http-equiv="X-UA-Compatible" />
7+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/chart.min.js"></script>
8+
<title>basic.buffer_encoding_decoding</title>
9+
<style>
10+
body {
11+
margin: 0;
12+
padding: 0;
13+
background: #ddd;
14+
}
15+
16+
.container {
17+
box-sizing: border-box;
18+
height: 96vh;
19+
width: 96vw;
20+
margin: 2vh 2vw;
21+
resize: both;
22+
overflow: hidden;
23+
padding: 20px;
24+
background: white;
25+
box-shadow: 0 0 15px #aaa;
26+
}
27+
</style>
28+
</head>
29+
<body>
30+
<div class="container">
31+
<canvas id="chart1666662556031" width="16" height="9"></canvas>
32+
</div>
33+
<script>
34+
const format = (num) => {
35+
const [whole, fraction] = String(num).split('.')
36+
const chunked = []
37+
whole
38+
.split('')
39+
.reverse()
40+
.forEach((char, index) => {
41+
if (index % 3 === 0) {
42+
chunked.unshift([char])
43+
} else {
44+
chunked[0].unshift(char)
45+
}
46+
})
47+
48+
const fractionStr = fraction !== undefined ? '.' + fraction : ''
49+
50+
return (
51+
chunked.map((chunk) => chunk.join('')).join(' ') + fractionStr
52+
)
53+
}
54+
const ctx1666662556031 = document
55+
.getElementById('chart1666662556031')
56+
.getContext('2d')
57+
const chart1666662556031 = new Chart(ctx1666662556031, {
58+
type: 'bar',
59+
data: {
60+
labels: ["JSON stringify and parse buffer","Base64 encode and decode buffer","Base64url encode and decode buffer"],
61+
datasets: [
62+
{
63+
data: [172634,1385074,1327362],
64+
backgroundColor: ["hsl(14.951999999999991, 85%, 55%)","hsl(120, 85%, 55%)","hsl(114.996, 85%, 55%)"],
65+
borderColor: ["hsl(14.951999999999991, 85%, 55%)","hsl(120, 85%, 55%)","hsl(114.996, 85%, 55%)"],
66+
borderWidth: 2,
67+
},
68+
],
69+
},
70+
options: {
71+
maintainAspectRatio: false,
72+
plugins: {
73+
title: {
74+
display: true,
75+
text: 'basic.buffer_encoding_decoding',
76+
font: { size: 20 },
77+
padding: 20,
78+
},
79+
legend: {
80+
display: false,
81+
},
82+
tooltip: {
83+
callbacks: {
84+
label: (context) => {
85+
return format(context.parsed.y) + ' ops/s'
86+
},
87+
},
88+
displayColors: false,
89+
backgroundColor: '#222222',
90+
padding: 10,
91+
cornerRadius: 5,
92+
intersect: false,
93+
},
94+
},
95+
scales: {
96+
x: {
97+
grid: {
98+
color: '#888888',
99+
},
100+
},
101+
y: {
102+
title: {
103+
display: true,
104+
text: 'Operations per second',
105+
padding: 10,
106+
},
107+
grid: {
108+
color: '#888888',
109+
},
110+
},
111+
},
112+
},
113+
})
114+
</script>
115+
</body>
116+
</html>

0 commit comments

Comments
 (0)