UNPKG

1.19 kBJavaScriptView Raw
1"use strict";
2
3const utils = require("./utils");
4
5const testDir = utils.prepareJetpackTestDir();
6let timer;
7let jetpackTime;
8let nativeTime;
9
10const test = testConfig => {
11 const dirJet = testDir.dir("to-be-removed-by-jetpack");
12 const dirNative = testDir.dir("to-be-removed-by-native");
13
14 console.log("");
15
16 return utils
17 .prepareFiles(dirJet, testConfig)
18 .then(() => {
19 return utils.prepareFiles(dirNative, testConfig);
20 })
21 .then(utils.waitAWhile)
22 .then(() => {
23 timer = utils.startTimer("jetpack.removeAsync()");
24 return dirJet.removeAsync();
25 })
26 .then(() => {
27 jetpackTime = timer();
28 return utils.waitAWhile();
29 })
30 .then(() => {
31 timer = utils.startTimer("Native rm -rf");
32 return utils.exec(`rm -rf ${dirNative.path()}`);
33 })
34 .then(() => {
35 nativeTime = timer();
36 utils.showDifferenceInfo(jetpackTime, nativeTime);
37 return utils.cleanAfterTest();
38 })
39 .catch(err => {
40 console.log(err);
41 });
42};
43
44const testConfigs = [
45 {
46 files: 10000,
47 size: 1000
48 }
49];
50
51const runNext = () => {
52 if (testConfigs.length > 0) {
53 test(testConfigs.pop()).then(runNext);
54 }
55};
56
57runNext();