Skip to content

Instantly share code, notes, and snippets.

@kebot
Created October 17, 2016 17:06
Show Gist options
  • Save kebot/fd756cbe1212d6f955bbbf13db6680d7 to your computer and use it in GitHub Desktop.
Save kebot/fd756cbe1212d6f955bbbf13db6680d7 to your computer and use it in GitHub Desktop.
time
// matchfilters performance: https://github.com/yarnpkg/yarn/blob/master/src/util/filter.js#L96
const path = require('path');
let filter = {
base: 'node_modules/xml-escape',
isNegation: false,
regex: /^(?:(?!\.)(?=.)[^\/]*?\.seed)$/i
},
basename = 'branches',
loc = '.git/branches'
let startTime = Date.now()
if (filter.base && filter.base !== '.') {
loc = path.relative(filter.base, loc);
}
filter.regex.test(loc) ||
filter.regex.test(`/${loc}`) ||
filter.regex.test(basename);
console.log('timediff', Date.now() - startTime);
>>> timediff 19ms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment