Giter Site home page Giter Site logo

fps-measurer's Introduction

fps-measurer

Performance testing certain types of things (eg FPS while a user is scrolling) can be tricky. Manual tests yield highly variable results which in turn makes A/B comparisons unreliable. This utility allows you to create simple, async test cases that can be run until a confidence interval is reached (aka a reliable FPS measurement has been taken).

Installation

Using Npm:

npm install --save-dev fps-measurer

UMD build:

<script src="https://npmcdn.com/fps-measurer/dist/umd/fps-measurer.js"></script>

Usage

Here is a basic example of how you can structure your tests:

import { TestRunner } from './TestRunner'

function yourTestCase (callback) {
  // Your test case goes here...
  // When it's done, invoke callback()
  // You can also return a Promise instead if you prefer that syntax
}

const testRunner = new TestRunner(yourTestCase)

// Will run until an acceptable confidence interval has been established.
// You can pass this function a callback (to be called on complete)
// Or you can await its returned Promise for completion
const data = await testRunner.start()
data.duration // mean duration across all runs
data.framerate // mean framerate across all runs

TestRunner API

constructor(testCase: Function, { maxSampleSize: number, minSampleSize: number })

The only required arugment for instantiating a TestRunner is a test case. Your test case can accept a callback or it can return a Promise to indicate completion. Optionally you may pass a configuration object to override the default min and max sample size (min = 5, max = 10 by default).

isRunning(): boolean

Tests are currently running.

start(completeCallback: ?Function): Promise

Start tests. You can pass a callback (to be executed on completion, and passed a data object) or youc an listen for the returned Promise. Calling this method when tests are already running will return a rejected Promise.

stop

Stops a running test. This method will error if tests are not running.

fps-measurer's People

Contributors

bvaughn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.