Skip to content

Commit

Permalink
Merge pull request #419 from MatrixAI/feature-concurrent-state
Browse files Browse the repository at this point in the history
Integrate js-db and concurrency testing
  • Loading branch information
tegefaulkes authored Aug 23, 2022
2 parents 27df70f + c75a402 commit 5d90a03
Show file tree
Hide file tree
Showing 107 changed files with 527 additions and 1,308 deletions.
3 changes: 2 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
},
"block": {
"exceptions": ["*"]
}
},
"markers": ["/"]
}
],
"capitalized-comments": [
Expand Down
20 changes: 10 additions & 10 deletions benches/gitgc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import path from 'path';
import b from 'benny';
import { suiteCommon } from './utils';

async function main () {
async function main() {
let map = new Map();
let obj = {};
let arr: any = [];
Expand All @@ -18,10 +18,10 @@ async function main () {
for (let i = 0; i < 1000; i++) {
map.delete(i);
}
for (const i of map) {
for (const _i of map) {
// NOOP
}
}
};
}),
b.add('obj', async () => {
obj = {};
Expand All @@ -32,26 +32,26 @@ async function main () {
for (let i = 0; i < 1000; i++) {
delete obj[i];
}
for (const i in obj) {
for (const _i in obj) {
// NOOP
}
};
}),
b.add('arr', async () => {
// you first have to count the number of objects
// You first have to count the number of objects
arr = [];
return async () => {
// you have to iterate for each object
// 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
// Double the vector
arr.length = arr.length * 2 || 2;
}
arr[i] = { id: i, mark: false };
// arr.push({ id: i, mark: false});
// Arr.push({ id: i, mark: false});
}
// this has to iterate the length of the array
// 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
Expand All @@ -74,7 +74,7 @@ async function main () {
for (let i = 0; i < 1000; i++) {
set.delete(i);
}
for (const i of set) {
for (const _i of set) {
// NOOP
}
};
Expand Down
5 changes: 4 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ module.exports = {
// Setup files after env are executed before each test file
// after the jest test environment is installed
// Can access globals
setupFilesAfterEnv: ['<rootDir>/tests/setupAfterEnv.ts'],
setupFilesAfterEnv: [
'jest-extended/all',
'<rootDir>/tests/setupAfterEnv.ts'
],
moduleNameMapper: moduleNameMapper,
};
Loading

0 comments on commit 5d90a03

Please sign in to comment.