Toggle navigation
Toggle navigation
This project
Loading...
Sign in
flutter_package
/
fluttertpc_get
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Jonatas
2020-10-25 16:46:46 -0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
96cdddce8edf7f5c379838a4be85f1e903f3e87e
96cdddce
1 parent
afc6f75b
improve benchmarks legibility
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
12 deletions
test/benchmarks/benckmark_test.dart
test/benchmarks/benckmark_test.dart
View file @
96cdddc
import
'dart:async'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:get/state_manager.dart'
;
int
times
=
3
;
...
...
@@ -15,8 +16,8 @@ Future<String> valueNotifier() {
value
.
addListener
(()
{
if
(
last
==
value
.
value
)
{
timer
.
stop
();
c
.
complete
(
"""
${value.value}
item value notifier
objs time:
${timer.elapsedMicroseconds}
ms"""
);
c
.
complete
(
"""
${value.value}
listeners notified | [VALUENOTIFIER] objs time:
${timer.elapsedMicroseconds}
ms"""
);
}
});
...
...
@@ -36,8 +37,8 @@ Future<String> getValue() {
value
.
addListener
(()
{
if
(
last
==
value
.
value
)
{
timer
.
stop
();
c
.
complete
(
"""
${value.value}
item get value objs
time:
${timer.elapsedMicroseconds}
ms"""
);
c
.
complete
(
"""
${value.value}
listeners notified | [GETX VALUE] objs time:
${timer.elapsedMicroseconds}
ms"""
);
}
});
...
...
@@ -58,7 +59,8 @@ Future<String> getStream() {
value
.
stream
.
listen
((
v
)
{
if
(
last
==
v
)
{
timer
.
stop
();
c
.
complete
(
"
$v
item stream objs time:
${timer.elapsedMicroseconds}
ms"
);
c
.
complete
(
"""
$v
listeners notified | [STREAM] objs time:
${timer.elapsedMicroseconds}
ms"""
);
}
});
...
...
@@ -70,13 +72,15 @@ Future<String> getStream() {
}
void
main
(
)
async
{
print
(
await
getValue
());
print
(
await
valueNotifier
());
print
(
await
getStream
());
times
=
30000
;
print
(
await
getValue
());
print
(
await
valueNotifier
());
print
(
await
getStream
());
test
(
'run benchmarks'
,
()
async
{
print
(
await
getValue
());
print
(
await
valueNotifier
());
print
(
await
getStream
());
times
=
30000
;
print
(
await
getValue
());
print
(
await
valueNotifier
());
print
(
await
getStream
());
});
}
typedef
VoidCallback
=
void
Function
();
...
...
Please
register
or
login
to post a comment