mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-24 04:58:45 +00:00
Fetch data in ConversationDataSource in parallel.
This commit is contained in:
committed by
Nicholas Tinsley
parent
e46759f436
commit
95c6f569d6
@@ -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()
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user