Files
flame/lib/profiler.dart
Renan Araujo e7ac8ed094 unecessary new
2019-03-22 13:20:18 -03:00

28 lines
458 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) {
tick();
}
void tick() {
dts.add(currentTime());
}
void end() {
tick();
Records.save(this);
}
static double currentTime() =>
DateTime.now().microsecondsSinceEpoch.toDouble() /
Duration.microsecondsPerMillisecond;
}