Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[convert] On web, consider using atob and btoa to implement Base64 codec #52007

Open
rakudrama opened this issue Apr 11, 2023 · 0 comments
Open
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. library-convert type-enhancement A request for a change that isn't a bug type-performance Issue relates to performance or code size web-dart2js

Comments

@rakudrama
Copy link
Member

It has been reported that Base64 decoding using the browser atob function followed by a copy loop to convert the result string into a Uint8List is 4-5x faster that using Base64.decode.

The main part of the decoder loop looks reasonable (other than the clumsy handling of outIndex++ which is not where the time is spent)

image

It seems that using atob will be worthwhile.

We did use TextDecoder to accelerate the decoding of UTF8 bytes into strings. Using the browser methods for Base64 conversion probably has similar issues:

  • There may be incompatibilities.
  • Errors may be reported differently (we might not care)
  • Acceleration using the browser methods is probably slower for small inputs, and testing for the cutoff point slows down all conversions.
@rakudrama rakudrama added area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-convert area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. labels Apr 11, 2023
@lrhn lrhn added type-enhancement A request for a change that isn't a bug type-performance Issue relates to performance or code size labels Apr 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. library-convert type-enhancement A request for a change that isn't a bug type-performance Issue relates to performance or code size web-dart2js
Projects
None yet
Development

No branches or pull requests

3 participants