Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix median computation #7

Closed
wants to merge 1 commit into from
Closed
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 @@ -308,6 +308,9 @@ void finishAndShowStats() {
activity.broadcastManager.unregisterReceiver(onIncomingTimestamp);
activity.clockManager.logDrift();

Utils.sort(deltasJ2N);
Utils.sort(deltas);

activity.logger.log("deltas: " + deltas.toString());
activity.logger.log(String.format(
"Median Java to native latency %.3f ms\nMedian audio latency %.1f ms",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ void finishAndShowStats() {
activity.broadcastManager.unregisterReceiver(onIncomingTimestamp);

// Show deltas and the median
Utils.sort(deltas);
activity.logger.log("deltas: " + deltas.toString());
activity.logger.log(String.format(
"Median latency %.1f ms",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,9 @@ private void printStats(int action) {
k2c.add((event.createTime - event.kernelTime) / 1000.);
}

Utils.sort(p2k);
Utils.sort(k2c);

activity.logger.log(p2k.toString());
activity.logger.log(k2c.toString());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,17 @@
package org.chromium.latency.walt;

import java.util.ArrayList;
import java.util.Collections;
import java.util.InputMismatchException;

/**
* Kitchen sink for small utility functions
*/
public class Utils {
public static void sort(ArrayList<Double> list) {
Collections.sort(list);
}

public static double median(ArrayList<Double> lst) {
int len = lst.size();
if (len == 0) {
Expand Down