Source:
private void onEnd(DeviceMetricData runData) { double minFPS = Double.MAX_VALUE; double maxFPS = 0.0; long totalTimeNs = 0; if (mDeviceResultData != null) { CLog.e("Intent timestamp: " + mDeviceResultData.getEvents(0).getTimestamp()); } try (BufferedWriter outputFile = new BufferedWriter(new FileWriter("/tmp/0/graphics-benchmark/out.txt", !mFirstRun))) { outputFile.write("Event count: " + mDeviceResultData.getEventsCount() + "\n"); long loadTime = mDeviceResultData.getEvents(0).getTimestamp() * 1000000; outputFile.write("Loaded at: " + loadTime + "\n"); outputFile.write("VSync Period: " + mVSyncPeriod + "\n"); outputFile.write("Times:\n"); Long prevTime = 0L; int numOfTimestamps = 0; for(Long time : mElapsedTimes) { if (time > loadTime) { if (prevTime == 0) { outputFile.write(time + "\n"); prevTime = time; continue; } Long timeDiff = time - prevTime; prevTime = time; double currentFPS = 1.0e9/timeDiff; minFPS = (currentFPS < minFPS ? currentFPS : minFPS); maxFPS = (currentFPS > maxFPS ? currentFPS : maxFPS); totalTimeNs += timeDiff; numOfTimestamps++; outputFile.write(time + " " + currentFPS + "\n"); } } outputFile.write("\nSTATS\n"); double avgFPS = numOfTimestamps * 1.0e9 / totalTimeNs; outputFile.write("min FPS = " + minFPS + "\n"); outputFile.write("max FPS = " + maxFPS + "\n"); outputFile.write("avg FPS = " + avgFPS + "\n"); runData.addStringMetric("min_fps", Double.toString(minFPS)); runData.addStringMetric("max_fps", Double.toString(maxFPS)); runData.addStringMetric("fps", Double.toString(avgFPS)); outputFile.write("\n"); } catch (IOException e) { throw new RuntimeException(e); } mFirstRun = false; }

Target:
private void onEnd(DeviceMetricData runData) { double minFPS = Double.MAX_VALUE; double maxFPS = 0.0; long totalTimeNs = 0; if (mDeviceResultData != null) { CLog.e("Intent timestamp: " + mDeviceResultData.getEvents(0).getTimestamp()); } try (BufferedWriter outputFile = new BufferedWriter(new FileWriter("/tmp/0/graphics-benchmark/out.txt", !mFirstRun))) { long loadTime = 0L; if (mDeviceResultData.getEventsCount() > 0) { loadTime = mDeviceResultData.getEvents(0).getTimestamp(); } else { CLog.e("No start benchmark intent given"); } outputFile.write("Started at: " + loadTime + " ms \n"); loadTime *= 1000000; outputFile.write("VSync Period: " + mVSyncPeriod + "\n\n"); outputFile.write("Frame Time\t\tFrames Per Second\n"); long prevTime = 0L; int numOfTimestamps = 0; for(long time : mElapsedTimes) { if (time > loadTime) { if (prevTime == 0) { prevTime = time; continue; } long timeDiff = time - prevTime; prevTime = time; double currentFPS = 1.0e9/timeDiff; minFPS = (currentFPS < minFPS ? currentFPS : minFPS); maxFPS = (currentFPS > maxFPS ? currentFPS : maxFPS); totalTimeNs += timeDiff; numOfTimestamps++; outputFile.write(timeDiff + " ms\t\t" + currentFPS + " fps\n"); } } outputFile.write("\nSTATS\n"); double avgFPS = numOfTimestamps * 1.0e9 / totalTimeNs; outputFile.write("min FPS = " + minFPS + "\n"); outputFile.write("max FPS = " + maxFPS + "\n"); outputFile.write("avg FPS = " + avgFPS + "\n"); runData.addStringMetric("min_fps", Double.toString(minFPS)); runData.addStringMetric("max_fps", Double.toString(maxFPS)); runData.addStringMetric("fps", Double.toString(avgFPS)); outputFile.write("\n"); } catch (IOException e) { throw new RuntimeException(e); } mFirstRun = false; }