Skip to content

Commit e1765dd

Browse files
committed
fix benchs
1 parent 974c32a commit e1765dd

3 files changed

Lines changed: 15 additions & 9 deletions

File tree

benchmarks/index.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
import { Suite } from 'benchmark';
2-
import { beforeAllHandler, prepare, test10, test11, test12, test13, test14, test8, test9, testMinus1, testMinus2, testMinus3, testMinus4, testMinus5, testMinus7, testMultiparentalTree, testMultipleWays, testPlus1, testPlus2, testPlus3, testPlus4, testPlus5, testPlus7, testtree } from '../imports/onedirectional';
2+
import { insertLink, insertNode, insertNodes, beforeAllHandler as beforeAllHandlerM, prepare as prepareM } from '../imports/multidirectional';
3+
import { beforeAllHandler as beforeAllHandlerO, prepare as prepareO, test10, test11, test12, test13, test14, test8, test9, testMinus1, testMinus2, testMinus3, testMinus4, testMinus5, testMinus7, testMultiparentalTree, testMultipleWays, testPlus1, testPlus2, testPlus3, testPlus4, testPlus5, testPlus7, testtree } from '../imports/onedirectional';
34

45
const DELAY = +process.env.DELAY || 0;
56
const delay = time => new Promise(res => setTimeout(res, time));
67

78
(async () => {
8-
await beforeAllHandler();
9-
await prepare();
9+
await beforeAllHandlerO();
10+
await prepareO();
11+
12+
await beforeAllHandlerM();
13+
const type_id = await prepareM();
1014

1115
var suite = new Suite();
12-
13-
// add tests
16+
1417
suite.add('testPlus1', { defer: true, fn: async function(deferred) {
1518
await testPlus1(false)();
1619
deferred.resolve();
@@ -99,7 +102,7 @@ const delay = time => new Promise(res => setTimeout(res, time));
99102
await testMultiparentalTree(false)();
100103
deferred.resolve();
101104
} });
102-
// add listeners
105+
103106
suite.on('cycle', function(event) {
104107
console.log(String(event.target));
105108
});

imports/multidirectional.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,19 +98,20 @@ export const countMp = async () => {
9898
return result?.data?.mp_example__links__mp_aggregate?.aggregate?.count;
9999
};
100100

101-
let type_id;
101+
export let type_id;
102102

103103
export const beforeAllHandler = async () => {
104104
if (type_id) {
105105
await clear(type_id);
106106
await deleteNode(type_id);
107107
}
108-
jest.setTimeout(1000000);
108+
if (global.jest) jest.setTimeout(1000000);
109109
};
110110
export const prepare = async () => {
111111
const ids = await insertNodes({});
112112
type_id = ids[0];
113113
debug('prepare', ids);
114+
return type_id;
114115
};
115116
export const testPlus15 = (needCheck = true) => async () => {
116117
debug('+15');

imports/onedirectional.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,19 +144,21 @@ export const generateMultiparentalTree = async (array, nodesHash, count = 100) =
144144
debug(`multiparental tree founded: ${founded}, skipped: ${skipped}`);
145145
};
146146

147-
let type_id;
147+
export let type_id;
148148

149149
export const beforeAllHandler = async () => {
150150
if (type_id) {
151151
await clear(type_id);
152152
await deleteNode(type_id);
153153
}
154154
if (global?.jest) jest.setTimeout(1000000);
155+
return type_id;
155156
};
156157
export const prepare = async () => {
157158
const ids = await insertNodes({});
158159
type_id = ids[0];
159160
debug('prepare', ids);
161+
return type_id;
160162
};
161163

162164
export const testPlus1 = (needCheck = true) => async () => {

0 commit comments

Comments
 (0)