Fetch data in ConversationDataSource in parallel.

This commit is contained in:
Greyson Parrelli
2023-08-30 15:57:46 -04:00
committed by Nicholas Tinsley
parent e46759f436
commit 95c6f569d6
21 changed files with 297 additions and 273 deletions

View File

@@ -0,0 +1,20 @@
/*
* Copyright 2023 Signal Messenger, LLC
* SPDX-License-Identifier: AGPL-3.0-only
*/
package org.signal.core.util
import kotlin.math.pow
import kotlin.math.round
/**
* Rounds a number to the specified number of places. e.g.
*
* 1.123456f.roundedString(2) = 1.12
* 1.123456f.roundedString(5) = 1.12346
*/
fun Double.roundedString(places: Int): String {
val powerMultiplier = 10f.pow(places)
return (round(this * powerMultiplier) / powerMultiplier).toString()
}

View File

@@ -9,7 +9,7 @@ import kotlin.math.pow
import kotlin.math.round
/**
* Rounds a number to the specififed number of places. e.g.
* Rounds a number to the specified number of places. e.g.
*
* 1.123456f.roundedString(2) = 1.12
* 1.123456f.roundedString(5) = 1.12346

View File

@@ -24,6 +24,10 @@ public class Stopwatch {
}
public void stop(@NonNull String tag) {
Log.d(tag, stopAndGetLogString(tag));
}
public String stopAndGetLogString(String tag) {
StringBuilder out = new StringBuilder();
out.append("[").append(title).append("] ");
@@ -43,9 +47,10 @@ public class Stopwatch {
out.append("total: ").append(splits.get(splits.size() - 1).time - startTime);
}
Log.d(tag, out.toString());
return out.toString();
}
private static class Split {
final long time;
final String label;