dart-sdk/benchmarks
Stephen Adams a4294c354c Benchmark for comparing reading Uint8List vs UnmodifiableUint8ListView
The benchmark reports per-element times for summing the elements of a typed-data List.

----

The VM implementation is quite good but it looks like there is still a little room for improvement since the views are 2x slower than a simple array.

dart compile exe:

TypedDataPoly.mono.array.2(RunTime): 1.9670880036279512 ns.
TypedDataPoly.A_V.array.2(RunTime): 4.392355 ns.
TypedDataPoly.A_V.view.2(RunTime): 5.730097499999999 ns.
TypedDataPoly.A_UV.array.2(RunTime): 4.455393750000001 ns.
TypedDataPoly.A_UV.view.2(RunTime): 5.811122500000001 ns.
TypedDataPoly.A_VUV.array.2(RunTime): 4.386336250000001 ns.
TypedDataPoly.A_VUV.view.2(RunTime): 5.7639675 ns.
TypedDataPoly.A_UVx5.array.2(RunTime): 4.62768 ns.
TypedDataPoly.A_UVx5.view.2(RunTime): 5.7099649999999995 ns.
TypedDataPoly.mega.array.2(RunTime): 5.272632499999999 ns.
TypedDataPoly.mega.mixed.2(RunTime): 5.62861 ns.

TypedDataPoly.mono.array.100(RunTime): 0.6455633088733822 ns.
TypedDataPoly.A_V.array.100(RunTime): 3.1558100965636964 ns.
TypedDataPoly.A_V.view.100(RunTime): 4.476973567105732 ns.
TypedDataPoly.A_UV.array.100(RunTime): 3.149724878714137 ns.
TypedDataPoly.A_UV.view.100(RunTime): 4.500062299750802 ns.
TypedDataPoly.A_VUV.array.100(RunTime): 3.1438380581862146 ns.
TypedDataPoly.A_VUV.view.100(RunTime): 4.499246259421757 ns.
TypedDataPoly.A_UVx5.array.100(RunTime): 3.1570175999999996 ns.
TypedDataPoly.A_UVx5.view.100(RunTime): 4.482889818440727 ns.
TypedDataPoly.mega.array.100(RunTime): 3.649420567570034 ns.
TypedDataPoly.mega.mixed.100(RunTime): 4.068594455581881 ns.


On the other hand, there is a massive performance tax for using UnmodifiableUint8ListView on the web, especially views of views.
https://github.com/dart-lang/sdk/issues/50255 discusses how this might be fixed.

compile js -O3:

TypedDataPoly.mono.array.2(RunTime): 2.209502118308509 ns.
TypedDataPoly.A_V.array.2(RunTime): 2.58625 ns.
TypedDataPoly.A_V.view.2(RunTime): 2.32 ns.
TypedDataPoly.A_UV.array.2(RunTime): 51.633530557495135 ns.
TypedDataPoly.A_UV.view.2(RunTime): 302.4986387561256 ns.
TypedDataPoly.A_VUV.array.2(RunTime): 52.19476512355694 ns.
TypedDataPoly.A_VUV.view.2(RunTime): 302.84394312113756 ns.
TypedDataPoly.A_UVx5.array.2(RunTime): 55.649763488505165 ns.
TypedDataPoly.A_UVx5.view.2(RunTime): 849.458699173131 ns.
TypedDataPoly.mega.array.2(RunTime): 59.75952192382461 ns.
TypedDataPoly.mega.mixed.2(RunTime): 142.7126082991336 ns.

TypedDataPoly.mono.array.100(RunTime): 0.9815000000000002 ns.
TypedDataPoly.A_V.array.100(RunTime): 1.1626947678735444 ns.
TypedDataPoly.A_V.view.100(RunTime): 1.2075 ns.
TypedDataPoly.A_UV.array.100(RunTime): 17.17602868362643 ns.
TypedDataPoly.A_UV.view.100(RunTime): 231.5 ns.
TypedDataPoly.A_VUV.array.100(RunTime): 16.85678073510773 ns.
TypedDataPoly.A_VUV.view.100(RunTime): 229.7 ns.
TypedDataPoly.A_UVx5.array.100(RunTime): 17.01657458563536 ns.
TypedDataPoly.A_UVx5.view.100(RunTime): 697.5524475524476 ns.
TypedDataPoly.mega.array.100(RunTime): 22.770700636942674 ns.
TypedDataPoly.mega.mixed.100(RunTime): 94.4 ns.

Change-Id: If8878efd4c57bbd87effcd1d3f1339bc0cffbd75
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/264897
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2022-10-21 00:53:59 +00:00
..
AsyncLiveVars Roll benchmark_harness and use AsyncBenchmarkBase. 2022-05-02 09:27:49 +00:00
BigIntParsePrint Fixed various typos in a lot of files 2022-07-25 12:21:59 +00:00
Calls
DartCLIStartup
Dynamic
EventLoopLatencyJson
EventLoopLatencyJson350KB
EventLoopLatencyRegexp
Example Fix typo 2022-08-04 09:22:39 +00:00
FfiAsTypedList
FfiBoringssl
FfiCall Reland "[vm/ffi] Throw on returning Error in Handle" 2022-10-03 12:25:08 +00:00
FfiMemory
FfiStruct
InstantiateTypeArgs [benchmarks] Address post-review comments for InstantiateTypeArgs. 2022-07-27 08:54:57 +00:00
IntegerSetLookup [gardening] Fix copyright statement typo. 2022-09-15 18:00:59 +00:00
Isolate [benchmarks] Follow-up to "Roll benchmark_harness" 2022-05-02 12:26:41 +00:00
IsolateBaseOverhead [vm/concurrency] Add IsolateBaseOverhead benchmark 2022-05-30 08:14:52 +00:00
IsolateFibonacci
IsolateJson
IsolateSendExitLatency Move benchmark IsolateSendExitLatency to correct directory 2022-06-07 16:50:40 +00:00
IsolateSpawn
IsolateSpawnMemory
Iterators
ListCopy
MapCopy
MapLookup
MD5
NativeCall
ObjectHash
Omnibus Add MapCopy to Omnibus benchmarks 2022-06-28 19:53:23 +00:00
OmnibusDeferred Add MapCopy to Omnibus benchmarks 2022-06-28 19:53:23 +00:00
Richards Fixed various typos in a lot of files 2022-07-25 12:21:59 +00:00
RuntimeType
SDKArtifactSizes Remove dartanalyzer from SDKArtifactSizes benchmark 2022-07-19 10:51:45 +00:00
SendPort
SHA1
SHA256
SkeletalAnimation
SkeletalAnimationSIMD
SoundSplayTreeSieve Fix typos 2022-09-16 19:35:00 +00:00
Startup [benchmarks] Apparently Golem has a metric called StartupTime. 2022-04-25 16:44:33 +00:00
StringPool
TypedDataDuplicate
TypedDataPoly/dart Benchmark for comparing reading Uint8List vs UnmodifiableUint8ListView 2022-10-21 00:53:59 +00:00
TypeLiteral/dart [vm] Add TypeLiteral benchmark 2022-04-25 08:49:12 +00:00
Utf8Decode
Utf8Encode
analysis_options.yaml
OWNERS