A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/nodejs/node/commit/a57b05e105 below:

add more options to cp-sync · nodejs/node@a57b05e · GitHub

File tree Expand file treeCollapse file tree 1 file changed

+38

-5

lines changed

Filter options

Expand file treeCollapse file tree 1 file changed

+38

-5

lines changed Original file line number Diff line number Diff line change

@@ -4,20 +4,53 @@ const common = require('../common');

4 4

const fs = require('fs');

5 5

const path = require('path');

6 6

const tmpdir = require('../../test/common/tmpdir');

7 -

tmpdir.refresh();

8 7 9 8

const bench = common.createBenchmark(main, {

10 9

n: [1, 100, 10_000],

10 +

dereference: ['true', 'false'],

11 +

force: ['true', 'false'],

11 12

});

12 13 13 -

function main({ n }) {

14 +

function prepareTestDirectory() {

15 +

const testDir = tmpdir.resolve(`test-cp-${process.pid}`);

16 +

fs.mkdirSync(testDir, { recursive: true });

17 + 18 +

fs.writeFileSync(path.join(testDir, 'source.txt'), 'test content');

19 + 20 +

fs.symlinkSync(

21 +

path.join(testDir, 'source.txt'),

22 +

path.join(testDir, 'link.txt'),

23 +

);

24 + 25 +

return testDir;

26 +

}

27 + 28 +

function main({ n, dereference, force }) {

14 29

tmpdir.refresh();

15 -

const options = { recursive: true };

16 -

const src = path.join(__dirname, '../../test/fixtures/copy');

30 + 31 +

const src = prepareTestDirectory();

17 32

const dest = tmpdir.resolve(`${process.pid}/subdir/cp-bench-${process.pid}`);

33 + 34 +

const options = {

35 +

recursive: true,

36 +

dereference: dereference === 'true',

37 +

force: force === 'true',

38 +

};

39 + 40 +

if (options.force) {

41 +

fs.cpSync(src, dest, { recursive: true });

42 +

}

43 + 18 44

bench.start();

19 45

for (let i = 0; i < n; i++) {

20 -

fs.cpSync(src, dest, options);

46 +

if (options.force) {

47 +

fs.cpSync(src, dest, options);

48 +

} else {

49 +

const uniqueDest = tmpdir.resolve(

50 +

`${process.pid}/subdir/cp-bench-${process.pid}-${i}`,

51 +

);

52 +

fs.cpSync(src, uniqueDest, options);

53 +

}

21 54

}

22 55

bench.end(n);

23 56

}

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4