Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
f7113083
Unverified
Commit
f7113083
authored
Jul 17, 2019
by
Jonah Williams
Committed by
GitHub
Jul 17, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add sync star benchmark cases (#36303)
parent
962a3cfd
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
230 additions
and
0 deletions
+230
-0
sync_star_bench.dart
...chmarks/microbenchmarks/lib/language/sync_star_bench.dart
+91
-0
sync_star_semantics_bench.dart
...crobenchmarks/lib/language/sync_star_semantics_bench.dart
+137
-0
microbenchmarks.dart
dev/devicelab/lib/tasks/microbenchmarks.dart
+2
-0
No files found.
dev/benchmarks/microbenchmarks/lib/language/sync_star_bench.dart
0 → 100644
View file @
f7113083
// Copyright 2019 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'../common.dart'
;
const
int
_kNumIterations
=
1000
;
const
int
_kNumWarmUp
=
100
;
void
main
(
)
{
assert
(
false
,
"Don't run benchmarks in checked mode! Use 'flutter run --release'."
);
// Warm up lap
for
(
int
i
=
0
;
i
<
_kNumWarmUp
;
i
+=
1
)
{
sumIterable
(
generateIterableSyncStar
());
sumIterable
(
generateIterableList
());
sumIterable
(
Iterable
<
int
>.
generate
(
100
,
generate
));
}
final
Stopwatch
watch
=
Stopwatch
();
watch
.
start
();
for
(
int
i
=
0
;
i
<
_kNumIterations
;
i
+=
1
)
{
sumIterable
(
generateIterableSyncStar
());
}
final
int
traverseIterableSyncStar
=
watch
.
elapsedMicroseconds
;
watch
..
reset
()
..
start
();
for
(
int
i
=
0
;
i
<
_kNumIterations
;
i
+=
1
)
{
sumIterable
(
generateIterableList
());
}
final
int
traverseIterableList
=
watch
.
elapsedMicroseconds
;
watch
..
reset
()
..
start
();
for
(
int
i
=
0
;
i
<
_kNumIterations
;
i
+=
1
)
{
sumIterable
(
Iterable
<
int
>.
generate
(
100
,
generate
));
}
final
int
traverseIterableGenerated
=
watch
.
elapsedMicroseconds
;
watch
..
reset
()
..
start
();
final
BenchmarkResultPrinter
printer
=
BenchmarkResultPrinter
();
const
double
scale
=
1000.0
/
_kNumIterations
;
printer
.
addResult
(
description:
'traverseIterableSyncStar'
,
value:
traverseIterableSyncStar
*
scale
,
unit:
'ns per iteration'
,
name:
'traverseIterableSyncStar_iteration'
,
);
printer
.
addResult
(
description:
'traverseIterableList'
,
value:
traverseIterableList
*
scale
,
unit:
'ns per iteration'
,
name:
'traverseIterableList_iteration'
,
);
printer
.
addResult
(
description:
'traverseIterableGenerated'
,
value:
traverseIterableGenerated
*
scale
,
unit:
'ns per iteration'
,
name:
'traverseIterableGenerated_iteration'
,
);
printer
.
printToStdout
();
}
int
generate
(
int
index
)
=>
index
;
// Generate an Iterable using a sync* method.
Iterable
<
int
>
generateIterableSyncStar
()
sync
*
{
for
(
int
i
=
0
;
i
<
100
;
i
++)
{
yield
i
;
}
}
// Generate an Iterable using a List.
Iterable
<
int
>
generateIterableList
()
{
final
List
<
int
>
items
=
<
int
>[];
for
(
int
i
=
0
;
i
<
100
;
i
++)
{
items
.
add
(
i
);
}
return
items
;
}
int
sumIterable
(
Iterable
<
int
>
values
)
{
int
result
=
0
;
for
(
int
value
in
values
)
{
result
+=
value
;
}
return
result
;
}
dev/benchmarks/microbenchmarks/lib/language/sync_star_semantics_bench.dart
0 → 100644
View file @
f7113083
// Copyright 2019 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:flutter/widgets.dart'
;
import
'../common.dart'
;
const
int
_kNumIterations
=
1000
;
const
int
_kNumWarmUp
=
100
;
void
main
(
)
{
final
List
<
String
>
words
=
'Lorem Ipsum is simply dummy text of the printing and'
'typesetting industry. Lorem Ipsum has been the industry
\'
s'
' standard dummy text ever since the 1500s, when an unknown'
' printer took a galley of type and scrambled it to make a'
' type specimen book'
.
split
(
' '
);
final
List
<
InlineSpanSemanticsInformation
>
data
=
<
InlineSpanSemanticsInformation
>[];
for
(
int
i
=
0
;
i
<
words
.
length
;
i
++)
{
if
(
i
.
isEven
)
{
data
.
add
(
InlineSpanSemanticsInformation
(
words
[
i
],
isPlaceholder:
false
),
);
}
else
if
(
i
%
2
==
0
)
{
data
.
add
(
InlineSpanSemanticsInformation
(
words
[
i
],
isPlaceholder:
true
),
);
}
}
print
(
words
);
// Warm up lap
for
(
int
i
=
0
;
i
<
_kNumWarmUp
;
i
+=
1
)
{
combineSemanticsInfoSyncStar
(
data
);
combineSemanticsInfoList
(
data
);
}
final
Stopwatch
watch
=
Stopwatch
();
watch
.
start
();
for
(
int
i
=
0
;
i
<
_kNumIterations
;
i
+=
1
)
{
consumeSpan
(
combineSemanticsInfoSyncStar
(
data
));
}
final
int
combineSemanticsInfoSyncStarTime
=
watch
.
elapsedMicroseconds
;
watch
..
reset
()
..
start
();
for
(
int
i
=
0
;
i
<
_kNumIterations
;
i
+=
1
)
{
consumeSpan
(
combineSemanticsInfoList
(
data
));
}
final
int
combineSemanticsInfoListTime
=
watch
.
elapsedMicroseconds
;
watch
..
reset
()
..
start
();
final
BenchmarkResultPrinter
printer
=
BenchmarkResultPrinter
();
const
double
scale
=
1000.0
/
_kNumIterations
;
printer
.
addResult
(
description:
'combineSemanticsInfoSyncStar'
,
value:
combineSemanticsInfoSyncStarTime
*
scale
,
unit:
'ns per iteration'
,
name:
'combineSemanticsInfoSyncStar_iteration'
,
);
printer
.
addResult
(
description:
'combineSemanticsInfoList'
,
value:
combineSemanticsInfoListTime
*
scale
,
unit:
'ns per iteration'
,
name:
'combineSemanticsInfoList_iteration'
,
);
printer
.
printToStdout
();
}
String
consumeSpan
(
Iterable
<
InlineSpanSemanticsInformation
>
items
)
{
String
result
=
''
;
for
(
InlineSpanSemanticsInformation
span
in
items
)
{
result
+=
span
.
text
;
}
return
result
;
}
Iterable
<
InlineSpanSemanticsInformation
>
combineSemanticsInfoSyncStar
(
List
<
InlineSpanSemanticsInformation
>
inputs
)
sync
*
{
String
workingText
=
''
;
String
workingLabel
;
for
(
InlineSpanSemanticsInformation
info
in
inputs
)
{
if
(
info
.
requiresOwnNode
)
{
if
(
workingText
!=
null
)
{
yield
InlineSpanSemanticsInformation
(
workingText
,
semanticsLabel:
workingLabel
??
workingText
);
workingText
=
''
;
workingLabel
=
null
;
}
yield
info
;
}
else
{
workingText
+=
info
.
text
;
workingLabel
??=
''
;
if
(
info
.
semanticsLabel
!=
null
)
{
workingLabel
+=
info
.
semanticsLabel
;
}
else
{
workingLabel
+=
info
.
text
;
}
}
}
if
(
workingText
!=
null
)
{
yield
InlineSpanSemanticsInformation
(
workingText
,
semanticsLabel:
workingLabel
);
}
else
{
assert
(
workingLabel
!=
null
);
}
}
Iterable
<
InlineSpanSemanticsInformation
>
combineSemanticsInfoList
(
List
<
InlineSpanSemanticsInformation
>
inputs
)
{
String
workingText
=
''
;
String
workingLabel
;
final
List
<
InlineSpanSemanticsInformation
>
result
=
<
InlineSpanSemanticsInformation
>[];
for
(
InlineSpanSemanticsInformation
info
in
inputs
)
{
if
(
info
.
requiresOwnNode
)
{
if
(
workingText
!=
null
)
{
result
.
add
(
InlineSpanSemanticsInformation
(
workingText
,
semanticsLabel:
workingLabel
??
workingText
));
workingText
=
''
;
workingLabel
=
null
;
}
result
.
add
(
info
);
}
else
{
workingText
+=
info
.
text
;
workingLabel
??=
''
;
if
(
info
.
semanticsLabel
!=
null
)
{
workingLabel
+=
info
.
semanticsLabel
;
}
else
{
workingLabel
+=
info
.
text
;
}
}
}
if
(
workingText
!=
null
)
{
result
.
add
(
InlineSpanSemanticsInformation
(
workingText
,
semanticsLabel:
workingLabel
));
}
else
{
assert
(
workingLabel
!=
null
);
}
return
result
;
}
dev/devicelab/lib/tasks/microbenchmarks.dart
View file @
f7113083
...
...
@@ -56,6 +56,8 @@ TaskFunction createMicrobenchmarkTask() {
...
await
_runMicrobench
(
'lib/gestures/velocity_tracker_bench.dart'
),
...
await
_runMicrobench
(
'lib/gestures/gesture_detector_bench.dart'
),
...
await
_runMicrobench
(
'lib/stocks/animation_bench.dart'
),
...
await
_runMicrobench
(
'lib/language/sync_star_bench.dart'
),
...
await
_runMicrobench
(
'lib/language/sync_star_semantics_bench.dart'
),
};
return
TaskResult
.
success
(
allResults
,
benchmarkScoreKeys:
allResults
.
keys
.
toList
());
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment