Files
flame/lib/profiler.dart
2018-05-21 01:59:07 -03:00

28 lines
477 B
Dart

class Records {
static void save(Profiler p) {
print('${p.name} : ${p.dts.last - p.dts.first} ms');
}
}
class Profiler {
final String name;
List<double> dts = [];
Profiler(this.name) {
this.tick();
}
void tick() {
this.dts.add(currentTime());
}
void end() {
this.tick();
Records.save(this);
}
static double currentTime() =>
new DateTime.now().microsecondsSinceEpoch.toDouble() /
Duration.microsecondsPerMillisecond;
}