stats-webgl

0.1.0 • Public • Published

stats-webgl

npm version

A pure webgl stats. now only support webgl2.

Features:

  • draw calls
  • shader compiling and texture uploading collecting
  • use EXT_disjoint_timer_query to collect gpu cost

Install

Npm:

npm install --save stats-webgl

CDN:

  • unpkg.com/stats-webgl/dist/stats-webgl.js

Usage

Call stats.begin(gl) before your render code, and call stats.end(gl) after your render code. Use stats.getCurrent() to get current stats info.

function animation() {
  stats.begin(gl);
  // do some render thing
  stats.end(gl);

  // get current stats info
  const currentStatsInfo = stats.getCurrent();

  requestAnimationFrame(animation);
}

Here is the stats info looks like:

{
    drawCalls: 0,

    drawArrayCalls: 0,
    drawElementsCalls: 0,
    drawArrayInstancedCalls: 0,
    drawElementsInstancedCalls: 0,

    faces: 0,
    vertices: 0,
    points: 0,

    useProgramCalls: 0,
    bindTextureCalls: 0,

    compileShaderCalls: 0,
    uploadTextureCalls: 0,

    cpuCost: 0,
    // if gpuCost is 0, 
    // it means your browser doesn't support EXT_disjoint_timer_query
    gpuCost: 0, 
}

Readme

Keywords

Package Sidebar

Install

npm i stats-webgl

Weekly Downloads

1

Version

0.1.0

License

MIT

Unpacked Size

17.7 kB

Total Files

5

Last publish

Collaborators

  • shawn0326