mirror of
https://github.com/deltachat/deltachat-android.git
synced 2025-10-05 19:41:57 +02:00
Create enterFilledChat and createAndEnterEmptyChats benchmarks (#2247)
This commit is contained in:
parent
48f64d26af
commit
24e82f6f35
1 changed files with 61 additions and 25 deletions
|
@ -47,35 +47,68 @@ public class EnterChatsBenchmark {
|
||||||
public ActivityScenarioRule<ConversationListActivity> activityRule = TestUtils.getOfflineActivityRule();
|
public ActivityScenarioRule<ConversationListActivity> activityRule = TestUtils.getOfflineActivityRule();
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void createAndEnterNChats() {
|
public void createAndEnter10FilledChats() {
|
||||||
if (!USE_EXISTING_CHATS) {
|
create10Chats(true);
|
||||||
createChatAndGoBack("Group #1", "Hello!", "Some links: https://testrun.org", "And a command: /help");
|
|
||||||
createChatAndGoBack("Group #2", "example.org, alice@example.org", "aaaaaaa", "bbbbbb");
|
|
||||||
createChatAndGoBack("Group #3", repeat("Some string ", 600), repeat("Another string", 200), "Hi!!!");
|
|
||||||
createChatAndGoBack("Group #4", "xyzabc", "Hi!!!!", "Let's meet!");
|
|
||||||
createChatAndGoBack("Group #5", repeat("aaaa", 40), "bbbbbbbbbbbbbbbbbb", "ccccccccccccccc");
|
|
||||||
createChatAndGoBack("Group #6", "aaaaaaaaaaa", repeat("Hi! ", 1000), "bbbbbbbbbb");
|
|
||||||
createChatAndGoBack("Group #7", repeat("abcdefg ", 500), repeat("xxxxx", 100), "yrrrrrrrrrrrrr");
|
|
||||||
createChatAndGoBack("Group #8", "and a number: 037362/384756", "ccccc", "Nice!");
|
|
||||||
createChatAndGoBack("Group #9", "ddddddddddddddddd", "zuuuuuuuuuuuuuuuu", "ccccc");
|
|
||||||
createChatAndGoBack("Group #10", repeat("xxxxxxyyyyy", 100), repeat("String!!", 10), "abcd");
|
|
||||||
}
|
|
||||||
|
|
||||||
String[] times = new String[GO_THROUGH_ALL_CHATS_N_TIMES];
|
String[] times = new String[GO_THROUGH_ALL_CHATS_N_TIMES];
|
||||||
for (int i = 0; i < GO_THROUGH_ALL_CHATS_N_TIMES; i++) {
|
for (int i = 0; i < GO_THROUGH_ALL_CHATS_N_TIMES; i++) {
|
||||||
times[i] = "" + timeGoToAllChats();
|
times[i] = "" + timeGoToNChats(10); // 10 group chats were created
|
||||||
}
|
}
|
||||||
Log.i(TAG, "MEASURED RESULTS (Benchmark) - Going thorough all 10 chats: " + String.join(",", times));
|
Log.i(TAG, "MEASURED RESULTS (Benchmark) - Going thorough all 10 chats: " + String.join(",", times));
|
||||||
}
|
}
|
||||||
|
|
||||||
private long timeGoToAllChats() {
|
@Test
|
||||||
|
public void createAndEnterEmptyChats() {
|
||||||
|
create10Chats(false);
|
||||||
|
|
||||||
|
String[] times = new String[GO_THROUGH_ALL_CHATS_N_TIMES];
|
||||||
|
for (int i = 0; i < GO_THROUGH_ALL_CHATS_N_TIMES; i++) {
|
||||||
|
times[i] = "" + timeGoToNChats(1);
|
||||||
|
}
|
||||||
|
Log.i(TAG, "MEASURED RESULTS (Benchmark) - Entering and leaving 1 empty chat: " + String.join(",", times));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void enterFilledChat() {
|
||||||
|
createChatAndGoBack("Group #1", true, "Hello!", "Some links: https://testrun.org", "And a command: /help");
|
||||||
|
|
||||||
|
String[] times = new String[50];
|
||||||
|
for (int i = 0; i < times.length; i++) {
|
||||||
|
long start = System.currentTimeMillis();
|
||||||
|
onView(withId(R.id.list)).perform(RecyclerViewActions.actionOnItemAtPosition(0, click()));
|
||||||
|
long end = System.currentTimeMillis();
|
||||||
|
long diff = end - start;
|
||||||
|
pressBack();
|
||||||
|
Log.i(TAG, "Measured (Benchmark) " + (i+1) + "/" + times.length + ": Entering 1 filled chat took " + diff + "ms " + "(going back took " + (System.currentTimeMillis() - end) + "ms)");
|
||||||
|
|
||||||
|
times[i] = "" + diff;
|
||||||
|
}
|
||||||
|
Log.i(TAG, "MEASURED RESULTS (Benchmark) - Entering 1 filled chat: " + String.join(",", times));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void create10Chats(boolean fillWithMsgs) {
|
||||||
|
if (!USE_EXISTING_CHATS) {
|
||||||
|
createChatAndGoBack("Group #1", fillWithMsgs, "Hello!", "Some links: https://testrun.org", "And a command: /help");
|
||||||
|
createChatAndGoBack("Group #2", fillWithMsgs, "example.org, alice@example.org", "aaaaaaa", "bbbbbb");
|
||||||
|
createChatAndGoBack("Group #3", fillWithMsgs, repeat("Some string ", 600), repeat("Another string", 200), "Hi!!!");
|
||||||
|
createChatAndGoBack("Group #4", fillWithMsgs, "xyzabc", "Hi!!!!", "Let's meet!");
|
||||||
|
createChatAndGoBack("Group #5", fillWithMsgs, repeat("aaaa", 40), "bbbbbbbbbbbbbbbbbb", "ccccccccccccccc");
|
||||||
|
createChatAndGoBack("Group #6", fillWithMsgs, "aaaaaaaaaaa", repeat("Hi! ", 1000), "bbbbbbbbbb");
|
||||||
|
createChatAndGoBack("Group #7", fillWithMsgs, repeat("abcdefg ", 500), repeat("xxxxx", 100), "yrrrrrrrrrrrrr");
|
||||||
|
createChatAndGoBack("Group #8", fillWithMsgs, "and a number: 037362/384756", "ccccc", "Nice!");
|
||||||
|
createChatAndGoBack("Group #9", fillWithMsgs, "ddddddddddddddddd", "zuuuuuuuuuuuuuuuu", "ccccc");
|
||||||
|
createChatAndGoBack("Group #10", fillWithMsgs, repeat("xxxxxxyyyyy", 100), repeat("String!!", 10), "abcd");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private long timeGoToNChats(int numChats) {
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < numChats; i++) {
|
||||||
onView(withId(R.id.list)).perform(RecyclerViewActions.actionOnItemAtPosition(i, click()));
|
onView(withId(R.id.list)).perform(RecyclerViewActions.actionOnItemAtPosition(i, click()));
|
||||||
pressBack();
|
pressBack();
|
||||||
}
|
}
|
||||||
long diff = System.currentTimeMillis() - start;
|
long diff = System.currentTimeMillis() - start;
|
||||||
Log.i(TAG, "Measured (Benchmark): Going through all chats took " + diff + "ms");
|
Log.i(TAG, "Measured (Benchmark): Going through " + numChats + " chats took " + diff + "ms");
|
||||||
return diff;
|
return diff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,17 +120,20 @@ public class EnterChatsBenchmark {
|
||||||
return s.toString();
|
return s.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createChatAndGoBack(String groupName, String text1, String text2, String text3) {
|
private void createChatAndGoBack(String groupName, boolean fillWithMsgs, String... texts) {
|
||||||
onView(withId(R.id.fab)).perform(click());
|
onView(withId(R.id.fab)).perform(click());
|
||||||
onView(withText(R.string.menu_new_group)).perform(click());
|
onView(withText(R.string.menu_new_group)).perform(click());
|
||||||
onView(withHint(R.string.group_name)).perform(replaceText(groupName));
|
onView(withHint(R.string.name_desktop)).perform(replaceText(groupName));
|
||||||
onView(withContentDescription(R.string.group_create_button)).perform(click());
|
onView(withContentDescription(R.string.group_create_button)).perform(click());
|
||||||
sendText(text1);
|
|
||||||
sendText(text2);
|
if (fillWithMsgs) {
|
||||||
sendText(text3);
|
for (String t: texts) {
|
||||||
sendText(text1);
|
sendText(t);
|
||||||
sendText(text2);
|
}
|
||||||
sendText(text3);
|
for (String t: texts) {
|
||||||
|
sendText(t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pressBack();
|
pressBack();
|
||||||
pressBack();
|
pressBack();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue