Skip to content

Commit c912598

Browse files
committed
benchmark scripts
1 parent ea84a58 commit c912598

File tree

9 files changed

+93
-0
lines changed

9 files changed

+93
-0
lines changed

benchmarks/npm.tar

16.6 MB
Binary file not shown.

benchmarks/npm.tar.gz

3.68 MB
Binary file not shown.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const tar = require('../..')
2+
const path = require('path')
3+
const file = process.argv[2] || path.resolve(__dirname, '../npm.tar')
4+
5+
const start = process.hrtime()
6+
tar.t({
7+
file: file
8+
}).then(_ => {
9+
const end = process.hrtime(start)
10+
console.error(end[0]*1e3 + end[1]/1e6)
11+
})
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
const tar = require('../..')
2+
const path = require('path')
3+
const file = process.argv[2] || path.resolve(__dirname, '../npm.tar')
4+
5+
const start = process.hrtime()
6+
tar.t({
7+
file: file,
8+
sync: true,
9+
maxReadSize: 17371648,
10+
noMtime: true
11+
})
12+
13+
const end = process.hrtime(start)
14+
console.error(end[0]*1e3 + end[1]/1e6)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const tar = require('../..')
2+
const path = require('path')
3+
const file = process.argv[2] || path.resolve(__dirname, '../npm.tar')
4+
const fs = require('fs')
5+
6+
const start = process.hrtime()
7+
const p = tar.t()
8+
p.on('end', _ => {
9+
const end = process.hrtime(start)
10+
console.error(end[0]*1e3 + end[1]/1e6)
11+
})
12+
fs.createReadStream(file).pipe(p)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const tar = require('../..')
2+
const path = require('path')
3+
const file = process.argv[2] || path.resolve(__dirname, '../npm.tar')
4+
const fs = require('fs')
5+
6+
const start = process.hrtime()
7+
const p = tar.t()
8+
p.on('end', _ => {
9+
const end = process.hrtime(start)
10+
console.error(end[0]*1e3 + end[1]/1e6)
11+
})
12+
p.end(fs.readFileSync(file))

benchmarks/parse/parse-async.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
const Parse = require('../../lib/parse.js')
2+
const path = require('path')
3+
const file = process.argv[2] || path.resolve(__dirname, '../npm.tar')
4+
const fs = require('fs')
5+
6+
const start = process.hrtime()
7+
const p = new Parse()
8+
p.on('entry', entry => entry.resume())
9+
p.on('end', _ => {
10+
const end = process.hrtime(start)
11+
console.error(end[0]*1e3 + end[1]/1e6)
12+
})
13+
fs.createReadStream(file).pipe(p)

benchmarks/parse/parse-sync.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
const Parse = require('../../lib/parse.js')
2+
const path = require('path')
3+
const file = process.argv[2] || path.resolve(__dirname, '../npm.tar')
4+
const fs = require('fs')
5+
const data = fs.readFileSync(file)
6+
7+
const start = process.hrtime()
8+
const p = new Parse()
9+
p.on('entry', entry => entry.resume())
10+
p.on('end', _ => {
11+
const end = process.hrtime(start)
12+
console.log(end[0]*1e3 + end[1]/1e6)
13+
})
14+
p.end(data)

benchmarks/parse/tar-stream.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const tar = require('tar-stream')
2+
const path = require('path')
3+
const file = process.argv[2] || path.resolve(__dirname, '../npm.tar')
4+
const fs = require('fs')
5+
6+
const start = process.hrtime()
7+
const p = tar.extract()
8+
p.on('entry', (entry, stream, callback) => {
9+
stream.on('end', callback)
10+
stream.resume()
11+
})
12+
p.on('data', _ => _)
13+
process.on('exit', (code, signal) => {
14+
const end = process.hrtime(start)
15+
console.log(end[0]*1e3 + end[1]/1e6)
16+
})
17+
fs.createReadStream(file).pipe(p)

0 commit comments

Comments
 (0)