Skip to main content

perf_tester 0.1.0 copy "perf_tester: ^0.1.0" to clipboard
perf_tester: ^0.1.0 copied to clipboard

Compare Dart and Flutter implementations: check that outputs match, time them, test whether the difference is significant, run AOT, and capture CPU profiles.

example/perf_tester_example.dart

// Run: dart run example/perf_tester_example.dart
import 'package:perf_tester/perf_tester.dart';

int loopSum(List<int> values) {
  var sum = 0;
  for (final value in values) {
    sum += value;
  }
  return sum;
}

int foldSum(List<int> values) => values.fold(0, (sum, value) => sum + value);

Future<void> main() async {
  await PerfTester<List<int>, int>(
    testName: 'Sum integer lists',
    testCases: [
      for (final size in [1000, 10000, 100000])
        List.generate(size, (index) => index % 100),
    ],
    implementation1: loopSum,
    implementation2: foldSum,
    impl1Name: 'Loop',
    impl2Name: 'Fold',
  ).run(warmupRuns: 20, benchmarkRuns: 30);
}
0
likes
0
points
3.99k
downloads

Publisher

verified publishertelosnex.com

Weekly Downloads

Compare Dart and Flutter implementations: check that outputs match, time them, test whether the difference is significant, run AOT, and capture CPU profiles.

Repository (GitHub)
View/report issues

Topics

#benchmark #performance #profiling #testing

License

unknown (license)

Dependencies

vm_service

More

Packages that depend on perf_tester