Skip to content

threeDart/stats.dart

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

stats.dart

Dart Performance Monitor

This class provides a simple info box that will help you monitor your code performance.

  • FPS Frames rendered in the last second. The higher the number the better.
  • MS Milliseconds needed to render a frame. The lower the number the better.

Screenshots

stats_js_fps.png stats_js_ms.png

Live Example

example

Getting Started

Create a Dart project and add a pubspec.yaml file to it

dependencies:
  stats:
    git: https://github.com/financeCoding/stats.dart.git

and run pub install to install stats (including its dependencies). Now add import

#import('package:stats/stats.dart');

Example

#import('dart:html');
#import('package:stats/stats.dart');
void main() {
  Stats stats = new Stats();
  document.body.elements.add(stats.container);
  CanvasElement canvas = new CanvasElement();
  canvas.width = 512;
  canvas.height = 512;
  document.body.elements.add(canvas);
  CanvasRenderingContext2D context = canvas.getContext('2d');
  context.fillStyle = 'rgba(127,0,255,0.05)';
  
  draw(time) {
    context.clearRect(0, 0, 512, 512);

    stats.begin();

    for (var i = 0; i < 2000; i++) {

      var x = Math.cos(time + i * 0.01) * 196 + 256;
      var y = Math.sin(time + i * 0.01234) * 196 + 256;

      context.beginPath();
      context.arc(x, y, 10, 0, Math.PI * 2, true);
      context.fill();

    }

    stats.end();
    window.requestAnimationFrame(draw);
  }
  
  window.requestAnimationFrame(draw);
}

Thanks

mrdoob for the stats.js code.

About

Simple stat counter in dart

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published