Skip to content

Instantly share code, notes, and snippets.

@jochasinga
Created July 15, 2022 15:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jochasinga/0109487de48ee73b685b2b6dec46467a to your computer and use it in GitHub Desktop.
Save jochasinga/0109487de48ee73b685b2b6dec46467a to your computer and use it in GitHub Desktop.
A test measuring elapsed time for calling `store` and `storeDirectory`
import { NFTStorage, File } from 'nft.storage'
describe('storeDirectory', () => {
const { AUTH_TOKEN, SERVICE_ENDPOINT } = process.env
const token = AUTH_TOKEN || ''
const endpoint = new URL(SERVICE_ENDPOINT || '')
let client = new NFTStorage({token, endpoint})
let times = []
it('testing elapsed time for storeDirectory', async () => {
const start = performance.now()
const cid = await client.storeDirectory([
new File(['hello world'], 'hello.txt'),
])
const end = performance.now()
console.log('elapsed time is: ', end - start)
}
})
})
describe('store', () => {
const { AUTH_TOKEN, SERVICE_ENDPOINT } = process.env
const token = AUTH_TOKEN || ''
const endpoint = new URL(SERVICE_ENDPOINT || '')
it('testing elapsed time for store', async () => {
let client = new NFTStorage({token, endpoint})
const payload = {
name: 'nft.storage store test',
description: 'Test ERC-1155 compatible metadata.',
image: new File(['<DATA>'], 'pinpie.jpg', { type: 'image/jpg' }),
}
const start = performance.now()
const metadata = await client.store(payload)
const end = performance.now()
console.log('elapsed time for store is: ', end - start)
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment