Skip to content

Commit

Permalink
bench marking
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed Jun 8, 2023
1 parent a658bbd commit 3d38525
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,18 @@ class XMTPModule : Module() {
// Generate a random wallet and set the client to that
AsyncFunction("createRandom") { environment: String ->
logV("createRandom")
val privateKey = PrivateKeyBuilder()
val options =
ClientOptions(api = apiEnvironments[environment] ?: apiEnvironments["dev"]!!)
val randomClient = Client().create(account = privateKey, options = options)
// Build from [8,54,32,15,250,250,23,163,203,139,84,242,45,106,250,96,177,61,164,135,38,84,50,65,173,197,194,80,219,176,224,205]
// or in hex 0836200ffafa17a3cb8b54f22d6afa60b13da48726543241adc5c250dbb0e0cd
// aka 2k many convos test wallet
// Create a ByteArray with the 32 bytes above
val privateKeyData = listOf(0x08, 0x36, 0x20, 0x0f, 0xfa, 0xfa, 0x17, 0xa3, 0xcb, 0x8b, 0x54, 0xf2, 0x2d, 0x6a, 0xfa, 0x60, 0xb1, 0x3d, 0xa4, 0x87, 0x26, 0x54, 0x32, 0x41, 0xad, 0xc5, 0xc2, 0x50, 0xdb, 0xb0, 0xe0, 0xcd)
.map { it.toByte() }
.toByteArray()
// Use hardcoded privateKey
val privateKey = PrivateKeyBuilder.buildFromPrivateKeyData(privateKeyData)
val privateKeyBuilder = PrivateKeyBuilder(privateKey)
val options = ClientOptions(api = apiEnvironments[environment] ?: apiEnvironments["dev"]!!)
val randomClient = Client().create(account = privateKeyBuilder, options = options)
clients[randomClient.address] = randomClient
randomClient.address
}
Expand Down
9 changes: 9 additions & 0 deletions example/src/ConversationListView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,20 @@ export default function ConversationListView({
const [messageCount, setMessageCount] = useState<number>(0);

async function refreshConversations() {
// Write code to time this function and divide by number of conversations
// to get an idea of how long it takes to load a conversation.
let start = Date.now();
const conversations = await client.conversations.list();
let end = Date.now();
console.log(
`Loaded ${conversations.length} conversations in ${end - start}ms`
);

const allMessages = await client.listBatchMessages(
conversations.map((conversation) => conversation.topic),
conversations.map((conversation) => conversation.conversationID)
);

setConversations(conversations);
setMessageCount(allMessages.length);
}
Expand Down
8 changes: 6 additions & 2 deletions ios/XMTPModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,12 @@ public class XMTPModule: Module {

// Generate a random wallet and set the client to that
AsyncFunction("createRandom") { (environment: String) -> String in
let privateKey = try PrivateKey.generate()
let options = XMTP.ClientOptions(api: apiEnvironments[environment] ?? apiEnvironments["dev"]!)
// Data from hex: 0836200ffafa17a3cb8b54f22d6afa60b13da48726543241adc5c250dbb0e0cd
// aka 2k many convo test wallet
let privateKeyData = Data([8,54,32,15,250,250,23,163,203,139,84,242,45,106,250,96,177,61,164,135,38,84,50,65,173,197,194,80,219,176,224,205])
let privateKey = try PrivateKey(privateKeyData)
// Use hardcoded privateKey for testing
let options = XMTP.ClientOptions(api: apiEnvironments[environment] ?? apiEnvironments["dev"]!)
let client = try await Client.create(account: privateKey, options: options)

self.clients[client.address] = client
Expand Down

0 comments on commit 3d38525

Please sign in to comment.