const fs = require('fs')

if (process.argv.length !== 3) {
  console.log('Usage: node benchmark.js <filename>')
  process.exit(1)
}

function measure(data, pattern) {
  const start = process.hrtime()

  const regex = new RegExp(pattern, 'g')
  const matches = data.match(regex)

  const end = process.hrtime(start);
  
  console.log((end[0] * 1e9 + end[1]) / 1e6 + ' - ' + matches.length);
}

const data = fs.readFileSync(process.argv[2], 'utf8')

// Email
measure(data, '[\\w.+-]+@[\\w.-]+\\.[\\w.-]+')

// URI
measure(data, '[\\w]+:\\/\\/[^\\/\\s?#]+[^\\s?#]+(?:\\?[^\\s#]*)?(?:#[^\\s]*)?')

// IP
measure(data, '(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9])\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9])')

@@ -270,16 +270,47 @@
 h(regex)
+%0A  const count = matches.length
 %0A%0A  cons
@@ -342,12 +342,9 @@
 art)
-;%0A  
+%0A
 %0A  c
@@ -398,24 +398,14 @@
 ' + 
-matches.length);
+count)
 %0A%7D%0A%0A

Update javascript code style