Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class PayloadTransformerTest {
fun test_dynamic_tuning_doesnt_change_if_max_size() {
val oldBytes = ByteString.of(*ByteArray(NDT7Constants.MAX_MESSAGE_SIZE))/* (1<<13) */

val newBytes = PayloadTransformer.performDynamicTuning(oldBytes, 0, 0.0)
val newBytes = PayloadTransformer.performDynamicTuning(oldBytes, 0, 0)

Assert.assertTrue(newBytes.size == oldBytes.size)
}
Expand All @@ -21,15 +21,15 @@ class PayloadTransformerTest {
fun test_dynamic_tuning_doesnt_change_if_queue_is_saturated() {
val oldBytes = ByteString.of(*ByteArray(1000))/* (1<<13) */

val newBytes = PayloadTransformer.performDynamicTuning(oldBytes, 0, 16000.0)
val newBytes = PayloadTransformer.performDynamicTuning(oldBytes, 0, 16000)

Assert.assertTrue(newBytes.size == oldBytes.size)
}
@Test
fun test_dynamic_tuning_will_double() {
val oldBytes = ByteString.of(*ByteArray(10))/* (1<<13) */

val newBytes = PayloadTransformer.performDynamicTuning(oldBytes, 10000, 16000.0)
val newBytes = PayloadTransformer.performDynamicTuning(oldBytes, 10000, 16000)

Assert.assertTrue(newBytes.size == oldBytes.size * 2)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Downloader(

private var startTime: Long = 0
private var previous: Long = 0
private var numBytes = 0.0
private var numBytes: Long = 0
private val gson = Gson()
private var webSocket: WebSocket? = null

Expand All @@ -34,7 +34,7 @@ class Downloader(
}

override fun onMessage(webSocket: WebSocket, text: String) {
numBytes += text.length.toDouble()
numBytes += text.length.toLong()
tryToUpdateClient()

try {
Expand All @@ -46,7 +46,7 @@ class Downloader(
}

override fun onMessage(webSocket: WebSocket, bytes: ByteString) {
numBytes += bytes.size.toDouble()
numBytes += bytes.size.toLong()
tryToUpdateClient()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Uploader(

private var startTime: Long = 0
private var previous: Long = 0
private var totalBytesSent = 0.0
private var totalBytesSent: Long = 0
private val gson = Gson()

override fun onMessage(webSocket: WebSocket, text: String) {
Expand Down Expand Up @@ -95,7 +95,7 @@ class Uploader(
tryToUpdateUpload(totalBytesSent, ws)
}

private fun tryToUpdateUpload(total: Double, ws: WebSocket) {
private fun tryToUpdateUpload(total: Long, ws: WebSocket) {
val now = currentTimeInMicroseconds()

// if we haven't sent an update in 250ms, lets send one
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ data class ClientResponse(

data class AppInfo(
@SerializedName("ElapsedTime") val elapsedTime: Long,
@SerializedName("NumBytes") val numBytes: Double
@SerializedName("NumBytes") val numBytes: Long
)
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import net.measurementlab.ndt7.android.models.ClientResponse

object DataConverter {

@JvmStatic fun generateResponse(startTime: Long, numBytes: Double, testType: NDTTest.TestType): ClientResponse {
@JvmStatic fun generateResponse(startTime: Long, numBytes: Long, testType: NDTTest.TestType): ClientResponse {
return ClientResponse(AppInfo(currentTimeInMicroseconds() - startTime, numBytes), test = testType.value)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ internal object PayloadTransformer {

// this is gonna let higher speed clients saturate their pipes better
// it will gradually increase the size of data if the websocket queue isn't filling up
fun performDynamicTuning(data: ByteString, queueSize: Long, bytesEnqueued: Double): ByteString {
fun performDynamicTuning(data: ByteString, queueSize: Long, bytesEnqueued: Long): ByteString {
val totalBytesTransmitted = bytesEnqueued - queueSize

return if (data.size * 2 < NDT7Constants.MAX_MESSAGE_SIZE && data.size < totalBytesTransmitted / 16) {
Expand Down