1 | "use strict";
|
2 |
|
3 | const utils = require("./utils");
|
4 |
|
5 | const testDir = utils.prepareJetpackTestDir();
|
6 | let timer;
|
7 | let jetpackTime;
|
8 | let nativeTime;
|
9 |
|
10 | const 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 |
|
44 | const testConfigs = [
|
45 | {
|
46 | files: 10000,
|
47 | size: 1000
|
48 | }
|
49 | ];
|
50 |
|
51 | const runNext = () => {
|
52 | if (testConfigs.length > 0) {
|
53 | test(testConfigs.pop()).then(runNext);
|
54 | }
|
55 | };
|
56 |
|
57 | runNext();
|