diff --git a/packages/w3up-client/test/memuse.test.js b/packages/w3up-client/test/memuse.test.js new file mode 100644 index 000000000..f7b549dcf --- /dev/null +++ b/packages/w3up-client/test/memuse.test.js @@ -0,0 +1,44 @@ +import * as Test from './test.js' +import * as Result from '../src/result.js' +import { randomCAR } from './helpers/random.js' + +/** + * @type {Test.Suite} + */ +export const testMem = { + 'test usage': async ( + assert, + { client, mail, connect, grantAccess, plansStorage } + ) => { + const space = await client.createSpace('test') + + const email = 'alice@web.mail' + const login = client.login(email) + const message = await mail.take() + assert.deepEqual(message.to, email) + await grantAccess(message) + const account = await login + + Result.try(await account.provision(space.did())) + await space.save() + + const car = await randomCAR(50_000_000) + const before = process.memoryUsage() + console.log(before) + + // @ts-expect-error + const link = await client.uploadCAR(car, { pieceHasher: null }) + + const after = process.memoryUsage() + + console.log({ + rss: after.rss - before.rss, + heapTotal: after.heapTotal - before.heapTotal, + heapUsed: after.heapUsed - before.heapUsed, + external: after.external - before.external, + arrayBuffers: after.arrayBuffers - before.arrayBuffers, + }) + }, +} + +Test.test({ MemoryUse: testMem }) diff --git a/packages/w3up-client/test/test.js b/packages/w3up-client/test/test.js index 7bf1f9105..356954751 100644 --- a/packages/w3up-client/test/test.js +++ b/packages/w3up-client/test/test.js @@ -2,6 +2,7 @@ import { StoreMemory } from '@web3-storage/access/stores/store-memory' import * as Context from '@web3-storage/upload-api/test/context' import * as Client from '@web3-storage/w3up-client' import * as assert from 'assert' +import * as http from 'http' /** * @typedef {Omit & {ok(value:unknown, message?:string):void}} Assert @@ -33,6 +34,7 @@ export const test = (suite) => { export const setup = async () => { const context = await Context.createContext({ + http, assert, })