Skip to content

Commit

Permalink
Add more peformance tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Dylan700 committed Dec 7, 2023
1 parent a20f8d1 commit 5427163
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions tests/performance/performance.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,59 @@ describe("Testing performance for uploading some 2MB files", () => {
})
})


describe("Testing performance for uploading some 1MB files", () => {
it("is fast", async () => {
// create some files to upload first
const promises = []
await execPromise("rm -rdf /tmp/upload && mkdir /tmp/upload")
for(let i = 0; i < 10; i++){
promises.push(execPromise(`head -c 1000000 </dev/urandom >/tmp/upload/${i}.bin`))
}
await Promise.all(promises)

const measurement = await measure(() => main(sftp), { meanUnder: 200, iterations: 50 })
console.info(`Mean: ${measurement.mean}ms`)
})
})

describe("Testing performance for uploading some 500KB files", () => {
it("is fast", async () => {
// create some files to upload first
const promises = []
await execPromise("rm -rdf /tmp/upload && mkdir /tmp/upload")
for(let i = 0; i < 20; i++){
promises.push(execPromise(`head -c 500000 </dev/urandom >/tmp/upload/${i}.bin`))
}
await Promise.all(promises)

const measurement = await measure(() => main(sftp), { meanUnder: 100, iterations: 100 })
console.info(`Mean: ${measurement.mean}ms`)
})
})

describe("Testing performance for uploading a large number of small files", () => {
it("is fast", async () => {
// create some files to upload first
const promises = []
await execPromise("rm -rdf /tmp/upload && mkdir /tmp/upload")
for(let i = 0; i < 100; i++){
promises.push(execPromise(`head -c 10000 </dev/urandom >/tmp/upload/${i}.bin`))
}
await Promise.all(promises)

const measurement = await measure(() => main(sftp), { meanUnder: 500, iterations: 50 })
console.info(`Mean: ${measurement.mean}ms`)
})
})

describe("Testing performance for uploading a single large file", () => {
it("is fast", async () => {
// create a large file to upload
await execPromise("rm -rdf /tmp/upload && mkdir /tmp/upload")
await execPromise(`head -c 50000000 </dev/urandom >/tmp/upload/large.bin`)

const measurement = await measure(() => main(sftp), { meanUnder: 2000, iterations: 10 })
console.info(`Mean: ${measurement.mean}ms`)
})
})

0 comments on commit 5427163

Please sign in to comment.