75e14ae102
* wip * fleshing out repo storage * fleshing out sql storage * cleaning things up * fix up tests * dumb bug - commit log reversed * rm staging in favor of commiting diffs to blockstore * clean up benches * fixing up sql storage * some caching for sql repo store * pr feedback * migration * wip * migraiton test * unclear param * sql repo storage tests * rm unused code * fix up some diff code * pr feedback * enum for action types * missed some * wip * ripping out auth lib * more auth cleanup * another lurker * wip better sync primitives * wip * improving diffs & sync * tests working! * actually implemented checkout lol * simplify interface & improve error handling * writing sql storage code * fixing up tests * testing & bugfixes * checkouts return records instead of cids * one last refactor lol * missed one * handle other cid codecs on incoming car verification * tests + tricky bugs * unneeded blockstore method * trim mst on del instead of save * cleanup comment * dont resolve did for every commit * use "commit" instead of "root" * getRoot -> getHead * pr feedback * very silly bug fix * improve sync output * reorging + sync of particular records * serve & verify proofs. also rename some ipld methods * fix up sync issue in mst * find reachable records form carfile * getRecord xrpc method * pr feedback * better migration test * check migraiton result * fixing up a couple things for pg * explicit migrateTo * async exceptions * ipld car mimetype + remove updateRepo * Update module publish scripts (#478) * Update pds package publishing scripts * Update auth package publishing scripts * Update crypto package publishing scripts * Update did-resolver package publishing scripts * Update handle package publishing scripts * Update xrpc-server package publishing scripts * Update common package publishing scripts * Update plc package publishing scripts * Update uri package publishing scripts * Update repo package publishing scripts * Sort "suggested follows" by number of posts (#477) * return suggestions by post count * pr feedback * fix up PG pagination issue * partiion commit-history & commit-blocks by user did * fix migration type * switch pk indexes Co-authored-by: Paul Frazee <pfrazee@gmail.com>
49 lines
1.3 KiB
TypeScript
49 lines
1.3 KiB
TypeScript
import { TID } from '@atproto/common'
|
|
import * as crypto from '@atproto/crypto'
|
|
import { Secp256k1Keypair } from '@atproto/crypto'
|
|
import { MemoryBlockstore, Repo, WriteOpAction } from '../src'
|
|
import * as util from '../tests/_util'
|
|
|
|
describe('Repo Benchmarks', () => {
|
|
const size = 10000
|
|
|
|
let blockstore: MemoryBlockstore
|
|
let keypair: crypto.Keypair
|
|
let repo: Repo
|
|
|
|
beforeAll(async () => {
|
|
blockstore = new MemoryBlockstore()
|
|
keypair = await Secp256k1Keypair.create()
|
|
repo = await Repo.create(blockstore, await keypair.did(), keypair)
|
|
})
|
|
|
|
it('calculates size', async () => {
|
|
for (let i = 0; i < size; i++) {
|
|
if (i % 500 === 0) {
|
|
console.log(i)
|
|
}
|
|
|
|
await repo.applyCommit(
|
|
{
|
|
action: WriteOpAction.Create,
|
|
collection: 'app.bsky.post',
|
|
rkey: TID.nextStr(),
|
|
value: {
|
|
$type: 'app.bsky.post',
|
|
text: util.randomStr(150),
|
|
reply: {
|
|
root: 'at://did:plc:1234abdefeoi23/app.bsky.post/12345678912345',
|
|
parent:
|
|
'at://did:plc:1234abdefeoi23/app.bsky.post/12345678912345',
|
|
},
|
|
createdAt: new Date().toISOString(),
|
|
},
|
|
},
|
|
keypair,
|
|
)
|
|
}
|
|
|
|
console.log('SIZE: ', await blockstore.sizeInBytes())
|
|
})
|
|
})
|