UNPKG

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