question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Calculation of FPS is not accurate

See original GitHub issue

Description:

After running this package with a release version of an app, I noticed that the FPS was always at 60. I downloaded the CSV from the generated web report and results in that CSV were also showing 60 FPS. So I debugged the calculation of FPS and I saw a comment:

Screenshot 2022-08-30 at 7 47 20 PM

But in my test cases automation is done to scroll the FlashList which means the list won’t be idle and the FPS generation in such case seems faulty. I also tried to log the frameTimes and it had 2 items only once. In every consequent calculations this frameTimes array is empty. Which makes the frameCount = 0 and we go to the assumption of FPS being 60, which is not precise.

Test case:

import { AppiumDriver } from "@bam.tech/appium-helper";
import { TestCase, measurePerformance } from "@perf-profiler/e2e";

const bundleId = "com.some.id";

const getTestCases = async () => {
  const driver = await AppiumDriver.create({
    appPackage: bundleId,
    appActivity: `${bundleId}.MainActivity`,
  });

  const scrollTestCase: TestCase = {
    beforeTest: async () => {
      driver.stopApp();
      driver.startApp();
      await driver.clickElementByText("someButton1");
      await driver.clickElementByText("someButton2");
    },
    run: async () => {
      await driver.wait(2000)
      for (let index = 0; index < 5; index++) {
          await driver.scrollDown(2);
      }

      await driver.clickElementById("someButton3");
    },
  };

  return {
    SCROLL: scrollTestCase,
  };
};

test("e2e", async () => {
  const testCases = await getTestCases();

  const { writeResults } = await measurePerformance(
    bundleId,
    testCases.SCROLL,
    1
  );
  writeResults();
});

Logs Output:

 console.log frameTimes  [ 50, 32.29 ]

  at processOutput (../android-performance-profiler/src/commands/gfxInfo/pollFpsUsage.ts:45:11)
      at Array.forEach (<anonymous>)

  console.log frameCount  2

  at processOutput (../android-performance-profiler/src/commands/gfxInfo/pollFpsUsage.ts:46:11)
      at Array.forEach (<anonymous>)

  console.log final FPS:  54.12520000000001

  at processOutput (../android-performance-profiler/src/commands/gfxInfo/pollFpsUsage.ts:63:11)
      at Array.forEach (<anonymous>)

 console.log frameTimes  []

  at processOutput (../android-performance-profiler/src/commands/gfxInfo/pollFpsUsage.ts:45:11)
      at Array.forEach (<anonymous>)

 console.log frameCount  0

  at processOutput (../android-performance-profiler/src/commands/gfxInfo/pollFpsUsage.ts:46:11)
      at Array.forEach (<anonymous>)

  console.log final FPS:  60

  at processOutput (../android-performance-profiler/src/commands/gfxInfo/pollFpsUsage.ts:63:11)
      at Array.forEach (<anonymous>)

  console.log frameTimes  []

  at processOutput (../android-performance-profiler/src/commands/gfxInfo/pollFpsUsage.ts:45:11)
      at Array.forEach (<anonymous>)

  console.log frameCount  0

  at processOutput (../android-performance-profiler/src/commands/gfxInfo/pollFpsUsage.ts:46:11)
      at Array.forEach (<anonymous>)

  console.log final FPS:  60

  at processOutput (../android-performance-profiler/src/commands/gfxInfo/pollFpsUsage.ts:63:11)
      at Array.forEach (<anonymous>)

  console.log frameTimes  []

  at processOutput (../android-performance-profiler/src/commands/gfxInfo/pollFpsUsage.ts:45:11)
      at Array.forEach (<anonymous>)

  console.log frameCount  0

  at processOutput (../android-performance-profiler/src/commands/gfxInfo/pollFpsUsage.ts:46:11)
      at Array.forEach (<anonymous>)

  console.log final FPS:  60

  at processOutput (../android-performance-profiler/src/commands/gfxInfo/pollFpsUsage.ts:63:11)
      at Array.forEach (<anonymous>)

  console.log frameTimes  []

  at processOutput (../android-performance-profiler/src/commands/gfxInfo/pollFpsUsage.ts:45:11)
      at Array.forEach (<anonymous>)

  console.log frameCount  0

  at processOutput (../android-performance-profiler/src/commands/gfxInfo/pollFpsUsage.ts:46:11)
      at Array.forEach (<anonymous>)

  console.log final FPS:  60

  at processOutput (../android-performance-profiler/src/commands/gfxInfo/pollFpsUsage.ts:63:11)
      at Array.forEach (<anonymous>)

  console.log frameTimes  []

  at processOutput (../android-performance-profiler/src/commands/gfxInfo/pollFpsUsage.ts:45:11)
      at Array.forEach (<anonymous>)

  console.log frameCount  0

  at processOutput (../android-performance-profiler/src/commands/gfxInfo/pollFpsUsage.ts:46:11)
      at Array.forEach (<anonymous>)

  console.log final FPS:  60

  at processOutput (../android-performance-profiler/src/commands/gfxInfo/pollFpsUsage.ts:63:11)
      at Array.forEach (<anonymous>)

  console.log frameTimes  []

  at processOutput (../android-performance-profiler/src/commands/gfxInfo/pollFpsUsage.ts:45:11)
      at Array.forEach (<anonymous>)

  console.log frameCount  0

  at processOutput (../android-performance-profiler/src/commands/gfxInfo/pollFpsUsage.ts:46:11)
      at Array.forEach (<anonymous>)

  console.log final FPS:  60

  at processOutput (../android-performance-profiler/src/commands/gfxInfo/pollFpsUsage.ts:63:11)
      at Array.forEach (<anonymous>)

  console.log frameTimes  []

  at processOutput (../android-performance-profiler/src/commands/gfxInfo/pollFpsUsage.ts:45:11)
      at Array.forEach (<anonymous>)

  console.log frameCount  0

  at processOutput (../android-performance-profiler/src/commands/gfxInfo/pollFpsUsage.ts:46:11)
      at Array.forEach (<anonymous>)

  console.log final FPS:  60

  at processOutput (../android-performance-profiler/src/commands/gfxInfo/pollFpsUsage.ts:63:11)
      at Array.forEach (<anonymous>)

  console.log frameTimes  []

  at processOutput (../android-performance-profiler/src/commands/gfxInfo/pollFpsUsage.ts:45:11)
      at Array.forEach (<anonymous>)

  console.log frameCount  0

  at processOutput (../android-performance-profiler/src/commands/gfxInfo/pollFpsUsage.ts:46:11)
      at Array.forEach (<anonymous>)

  console.log final FPS:  60

  at processOutput (../android-performance-profiler/src/commands/gfxInfo/pollFpsUsage.ts:63:11)
      at Array.forEach (<anonymous>)

  console.log frameTimes  []

  at processOutput (../android-performance-profiler/src/commands/gfxInfo/pollFpsUsage.ts:45:11)
      at Array.forEach (<anonymous>)

  console.log frameCount  0

  at processOutput (../android-performance-profiler/src/commands/gfxInfo/pollFpsUsage.ts:46:11)
      at Array.forEach (<anonymous>)

  console.log final FPS:  60

  at processOutput (../android-performance-profiler/src/commands/gfxInfo/pollFpsUsage.ts:63:11)
      at Array.forEach (<anonymous>)

  console.log frameTimes  []

  at processOutput (../android-performance-profiler/src/commands/gfxInfo/pollFpsUsage.ts:45:11)
      at Array.forEach (<anonymous>)

  console.log frameCount  0

  at processOutput (../android-performance-profiler/src/commands/gfxInfo/pollFpsUsage.ts:46:11)
      at Array.forEach (<anonymous>)

  console.log final FPS:  60

  at processOutput (../android-performance-profiler/src/commands/gfxInfo/pollFpsUsage.ts:63:11)
      at Array.forEach (<anonymous>)

  console.log frameTimes  []

  at processOutput (../android-performance-profiler/src/commands/gfxInfo/pollFpsUsage.ts:45:11)
      at Array.forEach (<anonymous>)

  console.log frameCount  0

  at processOutput (../android-performance-profiler/src/commands/gfxInfo/pollFpsUsage.ts:46:11)
      at Array.forEach (<anonymous>)

  console.log final FPS:  60

  at processOutput (../android-performance-profiler/src/commands/gfxInfo/pollFpsUsage.ts:63:11)
      at Array.forEach (<anonymous>)

  console.log frameTimes  []

  at processOutput (../android-performance-profiler/src/commands/gfxInfo/pollFpsUsage.ts:45:11)
      at Array.forEach (<anonymous>)

  console.log frameCount  0

  at processOutput (../android-performance-profiler/src/commands/gfxInfo/pollFpsUsage.ts:46:11)
      at Array.forEach (<anonymous>)

  console.log final FPS:  60

  at processOutput (../android-performance-profiler/src/commands/gfxInfo/pollFpsUsage.ts:63:11)
      at Array.forEach (<anonymous>)

  console.log frameTimes  []

  at processOutput (../android-performance-profiler/src/commands/gfxInfo/pollFpsUsage.ts:45:11)
      at Array.forEach (<anonymous>)

  console.log frameCount  0

  at processOutput (../android-performance-profiler/src/commands/gfxInfo/pollFpsUsage.ts:46:11)
      at Array.forEach (<anonymous>)

  console.log final FPS:  60

  at processOutput (../android-performance-profiler/src/commands/gfxInfo/pollFpsUsage.ts:63:11)
      at Array.forEach (<anonymous>)

  console.log frameTimes  []

  at processOutput (../android-performance-profiler/src/commands/gfxInfo/pollFpsUsage.ts:45:11)
      at Array.forEach (<anonymous>)

  console.log frameCount  0

  at processOutput (../android-performance-profiler/src/commands/gfxInfo/pollFpsUsage.ts:46:11)
      at Array.forEach (<anonymous>)

  console.log final FPS:  60

  at processOutput (../android-performance-profiler/src/commands/gfxInfo/pollFpsUsage.ts:63:11)
      at Array.forEach (<anonymous>)

  console.log frameTimes  []

  at processOutput (../android-performance-profiler/src/commands/gfxInfo/pollFpsUsage.ts:45:11)
      at Array.forEach (<anonymous>)

  console.log frameCount  0

  at processOutput (../android-performance-profiler/src/commands/gfxInfo/pollFpsUsage.ts:46:11)
      at Array.forEach (<anonymous>)

  console.log final FPS:  60

  at processOutput (../android-performance-profiler/src/commands/gfxInfo/pollFpsUsage.ts:63:11)
      at Array.forEach (<anonymous>)

  console.log frameTimes  []

  at processOutput (../android-performance-profiler/src/commands/gfxInfo/pollFpsUsage.ts:45:11)
      at Array.forEach (<anonymous>)

  console.log frameCount  0

  at processOutput (../android-performance-profiler/src/commands/gfxInfo/pollFpsUsage.ts:46:11)
      at Array.forEach (<anonymous>)

  console.log final FPS:  60

  at processOutput (../android-performance-profiler/src/commands/gfxInfo/pollFpsUsage.ts:63:11)
      at Array.forEach (<anonymous>)

  console.log frameTimes  []

  at processOutput (../android-performance-profiler/src/commands/gfxInfo/pollFpsUsage.ts:45:11)
      at Array.forEach (<anonymous>)

  console.log frameCount  0

  at processOutput (../android-performance-profiler/src/commands/gfxInfo/pollFpsUsage.ts:46:11)
      at Array.forEach (<anonymous>)

  console.log final FPS:  60

  at processOutput (../android-performance-profiler/src/commands/gfxInfo/pollFpsUsage.ts:63:11)
      at Array.forEach (<anonymous>)

  console.log frameTimes  []

  at processOutput (../android-performance-profiler/src/commands/gfxInfo/pollFpsUsage.ts:45:11)
      at Array.forEach (<anonymous>)

  console.log frameCount  0

  at processOutput (../android-performance-profiler/src/commands/gfxInfo/pollFpsUsage.ts:46:11)
      at Array.forEach (<anonymous>)

  console.log final FPS:  60

  at processOutput (../android-performance-profiler/src/commands/gfxInfo/pollFpsUsage.ts:63:11)
      at Array.forEach (<anonymous>)

  console.log frameTimes  []

  at processOutput (../android-performance-profiler/src/commands/gfxInfo/pollFpsUsage.ts:45:11)
      at Array.forEach (<anonymous>)

  console.log frameCount  0

  at processOutput (../android-performance-profiler/src/commands/gfxInfo/pollFpsUsage.ts:46:11)
      at Array.forEach (<anonymous>)

  console.log final FPS:  60

  at processOutput (../android-performance-profiler/src/commands/gfxInfo/pollFpsUsage.ts:63:11)
      at Array.forEach (<anonymous>)

  console.log frameTimes  []

  at processOutput (../android-performance-profiler/src/commands/gfxInfo/pollFpsUsage.ts:45:11)
      at Array.forEach (<anonymous>)

  console.log frameCount  0

  at processOutput (../android-performance-profiler/src/commands/gfxInfo/pollFpsUsage.ts:46:11)
      at Array.forEach (<anonymous>)

  console.log final FPS:  60

  at processOutput (../android-performance-profiler/src/commands/gfxInfo/pollFpsUsage.ts:63:11)
      at Array.forEach (<anonymous>)

 console.log [19:13:46] ✅  Finished iteration 1/1 in 10028.164417028427ms

  at log (../logger/index.ts:25:11)

Now this 2 items concluding to 54 FPS is not present in the CSV and also not reflected on the web page report.

CSV:

Screenshot 2022-08-30 at 8 01 41 PM

Report:

Screenshot 2022-08-30 at 7 03 00 PM

Let me know if I can help with anything else in explaining 🙂

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:2
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
Almourocommented, Sep 6, 2022

Thanks for all the details @hurali97 !

Right, I see what the issue is, the frame times are on your 3rd window in the list, which is the one seemingly active, but the script takes the first one by default. Should be able to fix that soon!

1reaction
Almourocommented, Sep 27, 2022

Hi @hurali97, sorry that it took so long~ 🙏

But the last version should drastically improve accuracy of measures! 🥳 The FPS measuring was completely overhauled and are retrieved via atrace now instead of gfxinfo

Let me know if that works for you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How accurate are the FPS calculations on PC-builds.com?
I would have to say, grossly inaccurate. They show much lower FPS that what can be achieved as they only take in 40%...
Read more >
performance - FPS measurement - Stack Overflow
Let's say we have timer with 1ms accuracy, and 60FPS frame rate. ... then calculate FPS = [number of frames] / [elapsed time]....
Read more >
FPS Counter with Average FPS Calculation? : r/pcmasterrace
I'm just looking for a clean, preferably customizable FPS counter that also calculates the average FPS that can be screen-recorded while ...
Read more >
How to calculate FPS and what factors affect FPS?
In general to calculate the FPS, you need the following: cn: counter of how many frames you've rendered; time_start: the time since you've ......
Read more >
Calculating FPS past requestAnimationFrame limit with ...
One of the simplest and best tools to measure performance of code that has to run in real-time is frames per second, FPS...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found