mirror of
https://github.com/briar/briar.git
synced 2025-12-23 23:37:43 -05:00
Create up to 10k max length forum posts for load testing.
This commit is contained in:
@@ -174,7 +174,7 @@
|
||||
android:id="@+id/seekBarForumMessages"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:max="50"
|
||||
android:max="10000"
|
||||
android:paddingTop="5dp"
|
||||
android:progress="20"
|
||||
app:layout_constraintEnd_toStartOf="@+id/TextViewForumMessagesSb"
|
||||
|
||||
@@ -470,20 +470,19 @@ public class TestDataCreatorImpl implements TestDataCreator {
|
||||
|
||||
private void createRandomForumPosts(Forum forum, List<Contact> contacts,
|
||||
int numForumPosts) throws DbException {
|
||||
List<ForumPost> posts = new ArrayList<>();
|
||||
List<MessageId> postIds = new ArrayList<>();
|
||||
for (int i = 0; i < numForumPosts; i++) {
|
||||
Contact contact = contacts.get(random.nextInt(contacts.size()));
|
||||
LocalAuthor author = localAuthors.get(contact);
|
||||
long timestamp = clock.currentTimeMillis() - (long) i * 60 * 1000;
|
||||
String text = getRandomText();
|
||||
MessageId parent = null;
|
||||
if (random.nextBoolean() && posts.size() > 0) {
|
||||
ForumPost parentPost = posts.get(random.nextInt(posts.size()));
|
||||
parent = parentPost.getMessage().getId();
|
||||
if (random.nextBoolean() && !postIds.isEmpty()) {
|
||||
parent = postIds.get(random.nextInt(postIds.size()));
|
||||
}
|
||||
ForumPost post = forumManager.createLocalPost(forum.getId(), text,
|
||||
timestamp, parent, author);
|
||||
posts.add(post);
|
||||
postIds.add(post.getMessage().getId());
|
||||
db.transaction(false, txn ->
|
||||
db.receiveMessage(txn, contact.getId(), post.getMessage()));
|
||||
}
|
||||
@@ -573,7 +572,7 @@ public class TestDataCreatorImpl implements TestDataCreator {
|
||||
}
|
||||
|
||||
private String getRandomText() {
|
||||
int minLength = 3 + random.nextInt(500);
|
||||
int minLength = 30_000;
|
||||
int maxWordLength = 15;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
while (sb.length() < minLength) {
|
||||
|
||||
Reference in New Issue
Block a user