forked from meganfrisella/gitgitgo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
42 lines (40 loc) · 1.24 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
const { indexIdf } = require("./bin/idxIdf");
const { indexTf } = require("./bin/idxTf");
const { crawler } = require("./bin/crawl");
const { start, promisify } = require("./bin/lib");
const distribution = require("./distribution");
const args = require("yargs").argv;
const main = () => {
let beforeCrawl = Date.now();
let beforeIndex = Date.now();
console.log("Crawling...");
console.log(beforeCrawl);
promisify(crawler)()
.then((res) => {
console.log("Computing index tf...");
beforeIndex = Date.now();
console.log(beforeIndex);
return promisify(indexTf)();
})
.then((res) =>
promisify(distribution.main.store.get)({
key: null,
col: "docs",
})
)
.then((res) => {
console.log("Computing index idf...");
console.log(Date.now());
return promisify(indexIdf)(res.length);
})
.then((res) => {
const afterIndex = Date.now();
console.log(afterIndex);
console.log("Crawl time:", beforeIndex - beforeCrawl);
console.log("Index time:", afterIndex - beforeIndex);
console.log("Total time:", afterIndex - beforeCrawl);
console.log(res);
})
.catch(console.error);
};
start(args.nodesConfig || "data/nodesConfig.json", main);