Created
July 15, 2022 15:59
-
-
Save jochasinga/0109487de48ee73b685b2b6dec46467a to your computer and use it in GitHub Desktop.
A test measuring elapsed time for calling `store` and `storeDirectory`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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