Skip to content
This repository has been archived by the owner on Jul 3, 2019. It is now read-only.

Commit

Permalink
perf: more copyFile benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
zkat committed Oct 16, 2017
1 parent 8c9ef3e commit 63787bb
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 2 deletions.
28 changes: 27 additions & 1 deletion test/benchmarks/content.read.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,33 @@ module.exports = (suite, CACHE) => {
}
})

suite.add('content.read.copy()', {
suite.add('content.read.copy() small data', {
defer: true,
setup () {
const fixture = new Tacks(CacheContent({
[INTEGRITY]: CONTENT
}))
fixture.create(CACHE)
},
fn (deferred) {
if (read.copy) {
read.copy(CACHE, INTEGRITY, path.join(CACHE, 'data'))
.then(
() => deferred.resolve(),
err => deferred.reject(err)
)
} else {
read(CACHE, INTEGRITY)
.then(data => fs.writeFileAsync(path.join(CACHE, 'data'), data))
.then(
() => deferred.resolve(),
err => deferred.reject(err)
)
}
}
})

suite.add('content.read.copy() big data', {
defer: true,
setup () {
const fixture = new Tacks(CacheContent({
Expand Down
37 changes: 36 additions & 1 deletion test/benchmarks/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

const CacheContent = require('../util/cache-content')
const memo = require('../../lib/memoization')
const path = require('path')
const Tacks = require('tacks')
const ssri = require('ssri')

Expand Down Expand Up @@ -77,7 +78,7 @@ module.exports = (suite, CACHE) => {
}
})

suite.add('get.stream() big data', {
suite.add('get.stream.byDigest() big data', {
defer: true,
setup () {
const fixture = new Tacks(CacheContent({
Expand All @@ -94,4 +95,38 @@ module.exports = (suite, CACHE) => {
})
}
})

suite.add('get.copy.byDigest() small data', {
defer: true,
setup () {
const fixture = new Tacks(CacheContent({
[INTEGRITY]: CONTENT
}))
fixture.create(CACHE)
},
fn (deferred) {
get.copy.byDigest(CACHE, INTEGRITY, path.join(CACHE, 'data'))
.then(
() => deferred.resolve(),
err => deferred.reject(err)
)
}
})

suite.add('get.copy.byDigest() big data', {
defer: true,
setup () {
const fixture = new Tacks(CacheContent({
[BIGINTEGRITY]: BIGCONTENT
}))
fixture.create(CACHE)
},
fn (deferred) {
get.copy.byDigest(CACHE, BIGINTEGRITY, path.join(CACHE, 'data'))
.then(
() => deferred.resolve(),
err => deferred.reject(err)
)
}
})
}

0 comments on commit 63787bb

Please sign in to comment.