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-17 13:30:32 -0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
1145dd200fb9366f43213ee7b416d1871d9cc90e
1145dd20
1 parent
59420fd9
add benchmarks from value notifier vs get value
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
82 additions
and
0 deletions
test/benchmarks/benckmark_test.dart
test/benchmarks/benckmark_test.dart
0 → 100644
View file @
1145dd2
import
'dart:async'
;
import
'package:flutter/foundation.dart'
;
import
'package:get/state_manager.dart'
;
int
times
=
3
;
int
get
last
=>
times
-
1
;
Future
<
String
>
valueNotifier
()
{
final
c
=
Completer
<
String
>();
final
value
=
ValueNotifier
<
int
>(
0
);
final
timer
=
Stopwatch
();
timer
.
start
();
value
.
addListener
(()
{
if
(
last
==
value
.
value
)
{
timer
.
stop
();
c
.
complete
(
"""
${value.value}
item value notifier
objs time:
${timer.elapsedMicroseconds}
ms"""
);
}
});
for
(
var
i
=
0
;
i
<
times
;
i
++)
{
value
.
value
=
i
;
}
return
c
.
future
;
}
Future
<
String
>
getValue
()
{
final
c
=
Completer
<
String
>();
final
value
=
Value
<
int
>(
0
);
final
timer
=
Stopwatch
();
timer
.
start
();
value
.
addListener
(()
{
if
(
last
==
value
.
value
)
{
timer
.
stop
();
c
.
complete
(
"""
${value.value}
item get value objs
time:
${timer.elapsedMicroseconds}
ms"""
);
}
});
for
(
var
i
=
0
;
i
<
times
;
i
++)
{
value
.
value
=
i
;
}
return
c
.
future
;
}
Future
<
String
>
getStream
()
{
final
c
=
Completer
<
String
>();
final
value
=
StreamController
<
int
>();
final
timer
=
Stopwatch
();
timer
.
start
();
value
.
stream
.
listen
((
v
)
{
if
(
last
==
v
)
{
timer
.
stop
();
c
.
complete
(
"
$v
item stream objs time:
${timer.elapsedMicroseconds}
ms"
);
}
});
for
(
var
i
=
0
;
i
<
times
;
i
++)
{
value
.
add
(
i
);
}
return
c
.
future
;
}
void
main
(
)
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