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

Introducing vault sharing and the restrictions of pulling and cloning with vault permissions #266

Merged
merged 10 commits into from
Mar 9, 2022
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
104 changes: 104 additions & 0 deletions benches/gitgc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import b from 'benny';
import packageJson from '../package.json';

async function main () {
let map = new Map();
let obj = {};
let arr = [];
let set = new Set();
const summary = await b.suite(
'gitgc',
b.add('map', async () => {
map = new Map();
return async () => {
for (let i = 0; i < 1000; i++) {
map.set(i, undefined);
}
for (let i = 0; i < 1000; i++) {
map.delete(i);
}
for (const i of map) {
// NOOP
}
}
}),
b.add('obj', async () => {
obj = {};
return async () => {
for (let i = 0; i < 1000; i++) {
obj[i] = undefined;
}
for (let i = 0; i < 1000; i++) {
delete obj[i];
}
for (const i in obj) {
// NOOP
}
};
}),
b.add('arr', async () => {
// you first have to count the number of objects
arr = [];
return async () => {
// you have to iterate for each object
// then for each value in length
for (let i = 0; i < 1000; i++) {
if (i === arr.length) {
// double the vector
arr.length = arr.length * 2 || 2;
}
arr[i] = { id: i, mark: false };
// arr.push({ id: i, mark: false});
}
// this has to iterate the length of the array
// but stop as soon as it reaches the end
// it gets complicate, but for 5x improvement
// it could be interesting
for (let i = 0; i < 1000; i++) {
arr[i].mark = true;
}
for (let i = 0; i < 1000; i++) {
if (arr[i].mark === false) {
// NOOP
}
}
};
}),
b.add('set', async () => {
set = new Set();
return async () => {
for (let i = 0; i < 1000; i++) {
set.add(i);
}
for (let i = 0; i < 1000; i++) {
set.delete(i);
}
for (const i of set) {
// NOOP
}
};
}),
b.cycle(),
b.complete(),
b.save({
file: 'gitgc',
folder: 'benches/results',
version: packageJson.version,
details: true,
}),
b.save({
file: 'gitgc',
folder: 'benches/results',
format: 'chart.html',
}),
);
return summary;
}

if (require.main === module) {
(async () => {
await main();
})();
}

export default main;
26 changes: 26 additions & 0 deletions benches/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env node

import fs from 'fs';
import si from 'systeminformation';
import gitgc from './gitgc';

async function main(): Promise<void> {
await gitgc();
const systemData = await si.get({
cpu: '*',
osInfo: 'platform, distro, release, kernel, arch',
system: 'model, manufacturer',
});
await fs.promises.writeFile(
'benches/results/system.json',
JSON.stringify(systemData, null, 2),
);
}

if (require.main === module) {
(async () => {
await main();
})();
}

export default main;
116 changes: 116 additions & 0 deletions benches/results/gitgc.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/[email protected]/dist/chart.min.js"></script>
<title>gitgc</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="chart1643349110845" 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 ctx1643349110845 = document
.getElementById('chart1643349110845')
.getContext('2d')
const chart1643349110845 = new Chart(ctx1643349110845, {
type: 'bar',
data: {
labels: ["map","obj","arr","set"],
datasets: [
{
data: [12413,17311,80712,16847],
backgroundColor: ["hsl(18.455999999999996, 85%, 55%)","hsl(25.740000000000002, 85%, 55%)","hsl(120, 85%, 55%)","hsl(25.044000000000008, 85%, 55%)"],
borderColor: ["hsl(18.455999999999996, 85%, 55%)","hsl(25.740000000000002, 85%, 55%)","hsl(120, 85%, 55%)","hsl(25.044000000000008, 85%, 55%)"],
borderWidth: 2,
},
],
},
options: {
maintainAspectRatio: false,
plugins: {
title: {
display: true,
text: 'gitgc',
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