Showing
1 changed file
with
9 additions
and
5 deletions
1 | import 'dart:async'; | 1 | import 'dart:async'; |
2 | 2 | ||
3 | import 'package:flutter/foundation.dart'; | 3 | import 'package:flutter/foundation.dart'; |
4 | +import 'package:flutter_test/flutter_test.dart'; | ||
4 | import 'package:get/state_manager.dart'; | 5 | import 'package:get/state_manager.dart'; |
5 | 6 | ||
6 | int times = 3; | 7 | int times = 3; |
@@ -15,8 +16,8 @@ Future<String> valueNotifier() { | @@ -15,8 +16,8 @@ Future<String> valueNotifier() { | ||
15 | value.addListener(() { | 16 | value.addListener(() { |
16 | if (last == value.value) { | 17 | if (last == value.value) { |
17 | timer.stop(); | 18 | timer.stop(); |
18 | - c.complete("""${value.value} item value notifier | ||
19 | -objs time: ${timer.elapsedMicroseconds}ms"""); | 19 | + c.complete( |
20 | + """${value.value} listeners notified | [VALUENOTIFIER] objs time: ${timer.elapsedMicroseconds}ms"""); | ||
20 | } | 21 | } |
21 | }); | 22 | }); |
22 | 23 | ||
@@ -36,8 +37,8 @@ Future<String> getValue() { | @@ -36,8 +37,8 @@ Future<String> getValue() { | ||
36 | value.addListener(() { | 37 | value.addListener(() { |
37 | if (last == value.value) { | 38 | if (last == value.value) { |
38 | timer.stop(); | 39 | timer.stop(); |
39 | - c.complete("""${value.value} item get value objs | ||
40 | - time: ${timer.elapsedMicroseconds}ms"""); | 40 | + c.complete( |
41 | + """${value.value} listeners notified | [GETX VALUE] objs time: ${timer.elapsedMicroseconds}ms"""); | ||
41 | } | 42 | } |
42 | }); | 43 | }); |
43 | 44 | ||
@@ -58,7 +59,8 @@ Future<String> getStream() { | @@ -58,7 +59,8 @@ Future<String> getStream() { | ||
58 | value.stream.listen((v) { | 59 | value.stream.listen((v) { |
59 | if (last == v) { | 60 | if (last == v) { |
60 | timer.stop(); | 61 | timer.stop(); |
61 | - c.complete("$v item stream objs time: ${timer.elapsedMicroseconds}ms"); | 62 | + c.complete( |
63 | + """$v listeners notified | [STREAM] objs time: ${timer.elapsedMicroseconds}ms"""); | ||
62 | } | 64 | } |
63 | }); | 65 | }); |
64 | 66 | ||
@@ -70,6 +72,7 @@ Future<String> getStream() { | @@ -70,6 +72,7 @@ Future<String> getStream() { | ||
70 | } | 72 | } |
71 | 73 | ||
72 | void main() async { | 74 | void main() async { |
75 | + test('run benchmarks', () async { | ||
73 | print(await getValue()); | 76 | print(await getValue()); |
74 | print(await valueNotifier()); | 77 | print(await valueNotifier()); |
75 | print(await getStream()); | 78 | print(await getStream()); |
@@ -77,6 +80,7 @@ void main() async { | @@ -77,6 +80,7 @@ void main() async { | ||
77 | print(await getValue()); | 80 | print(await getValue()); |
78 | print(await valueNotifier()); | 81 | print(await valueNotifier()); |
79 | print(await getStream()); | 82 | print(await getStream()); |
83 | + }); | ||
80 | } | 84 | } |
81 | 85 | ||
82 | typedef VoidCallback = void Function(); | 86 | typedef VoidCallback = void Function(); |
-
Please register or login to post a comment