Skip to content

Commit 5239a78

Browse files
rakudramaCommit Queue
authored and
Commit Queue
committed
[benchmarks] Update TypedDataPoly benchmark
Update TypedDataPoly benchmark to use `asUnmodifiableView()` instead of the deprecated typed data view constructors. Bug: #53785 Change-Id: I02381e3db37f44b01da25d7cbd728b525ff4899e Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332161 Reviewed-by: William Hesse <[email protected]> Commit-Queue: Stephen Adams <[email protected]>
1 parent 6a464c9 commit 5239a78

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

benchmarks/TypedDataPoly/dart/TypedDataPoly.dart

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import 'package:benchmark_harness/benchmark_harness.dart';
1010
//
1111
// The set of benchmarks compares the cost of reading typed data lists, mostly
1212
// different kinds of [Uint8List] - plain [Uint8List]s, [Uint8List]s that are
13-
// views of another [Uint8List], and [UnmodifiableUint8ListView]s of these.
13+
// views of another [Uint8List], and unmodifiable views of these.
1414
//
1515
// The benchmarks do not try to use external [Uint8List]s, since this is does
1616
// not easily translate to the web.
@@ -168,15 +168,15 @@ class Polymorphic1 extends Base {
168168
}
169169

170170
/// [Polymorphic2] calls `sum` with a flat allocated [Uint8List] and an
171-
/// [UnmodifiableUint8ListView] of the same list. This mildly polymorphic, so
171+
/// unmodifiable view of the same list. This mildly polymorphic, so
172172
/// there is the possibility that `sum` runs slower than [Monomorphic.sum].
173173
///
174174
/// The workload can be varied:
175175
///
176-
/// - `view` measures the cost of accessing the [UnmodifiableUint8ListView].
176+
/// - `view` measures the cost of accessing the unmodifiable view.
177177
///
178178
/// - `array` measures the cost of accessing a simple [Uint8List] using the
179-
/// same code that can also access an [UnmodifiableUint8ListView].
179+
/// same code that can also access an unmodifiable view of a [Uint8List].
180180
class Polymorphic2 extends Base {
181181
final List<int> data1;
182182
final List<int> data2;
@@ -185,7 +185,7 @@ class Polymorphic2 extends Base {
185185

186186
factory Polymorphic2(int n, String variant) {
187187
final data1 = Uint8List(n)..setToOnes();
188-
final data2 = UnmodifiableUint8ListView(data1);
188+
final data2 = data1.asUnmodifiableView();
189189
if (variant == 'array') return Polymorphic2._(n, variant, data1, data1);
190190
if (variant == 'view') return Polymorphic2._(n, variant, data2, data2);
191191
throw UnimplementedError('No variant "$variant"');
@@ -219,7 +219,7 @@ class Polymorphic2 extends Base {
219219
}
220220

221221
/// [Polymorphic3] is similar to [Polymorphic2], but the 'other' list is an
222-
/// [UnmodifiableUint8ListView] of a modifiable view.
222+
/// unmodifiable view of a modifiable view.
223223
class Polymorphic3 extends Base {
224224
final List<int> data1;
225225
final List<int> data2;
@@ -228,7 +228,7 @@ class Polymorphic3 extends Base {
228228
factory Polymorphic3(int n, String variant) {
229229
final data1 = Uint8List(n)..setToOnes();
230230
final view1 = Uint8List.sublistView(Uint8List(n + 1)..setToOnes(), 1);
231-
final data2 = UnmodifiableUint8ListView(view1);
231+
final data2 = view1.asUnmodifiableView();
232232
if (variant == 'array') return Polymorphic3._(n, variant, data1, data1);
233233
if (variant == 'view') return Polymorphic3._(n, variant, data2, data2);
234234
throw UnimplementedError('No variant "$variant"');
@@ -261,7 +261,7 @@ class Polymorphic3 extends Base {
261261
}
262262
}
263263

264-
/// [Polymorphic4] stacks [UnmodifiableUint8ListView]s five levels deep.
264+
/// [Polymorphic4] stacks unmodifiable views five levels deep.
265265
class Polymorphic4 extends Base {
266266
final List<int> data1;
267267
final List<int> data2;
@@ -270,11 +270,11 @@ class Polymorphic4 extends Base {
270270

271271
factory Polymorphic4(int n, String variant) {
272272
final data1 = Uint8List(n)..setToOnes();
273-
var data2 = UnmodifiableUint8ListView(data1);
274-
data2 = UnmodifiableUint8ListView(data2);
275-
data2 = UnmodifiableUint8ListView(data2);
276-
data2 = UnmodifiableUint8ListView(data2);
277-
data2 = UnmodifiableUint8ListView(data2);
273+
var data2 = data1.asUnmodifiableView();
274+
data2 = data2.asUnmodifiableView();
275+
data2 = data2.asUnmodifiableView();
276+
data2 = data2.asUnmodifiableView();
277+
data2 = data2.asUnmodifiableView();
278278
if (variant == 'array') return Polymorphic4._(n, variant, data1, data1);
279279
if (variant == 'view') return Polymorphic4._(n, variant, data2, data2);
280280
throw UnimplementedError('No variant "$variant"');
@@ -342,11 +342,11 @@ class Polymorphic5 extends Base {
342342
final data4 = Int8List(n)..setToOnes();
343343
final data5 = Int16List(n)..setToOnes();
344344

345-
final data6 = UnmodifiableUint8ListView(data1);
346-
final data7 = UnmodifiableUint16ListView(data2);
347-
final data8 = UnmodifiableUint32ListView(data3);
348-
final data9 = UnmodifiableInt8ListView(data4);
349-
final data10 = UnmodifiableInt16ListView(data5);
345+
final data6 = data1.asUnmodifiableView();
346+
final data7 = data2.asUnmodifiableView();
347+
final data8 = data3.asUnmodifiableView();
348+
final data9 = data4.asUnmodifiableView();
349+
final data10 = data5.asUnmodifiableView();
350350

351351
if (variant == 'array') {
352352
return Polymorphic5._(n, variant, data1, data1, data1, data1, data1,

0 commit comments

Comments
 (0)