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

performance: double.toString #17622

Open
DartBot opened this issue Mar 19, 2014 · 4 comments
Open

performance: double.toString #17622

DartBot opened this issue Mar 19, 2014 · 4 comments
Labels
area-vm Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends. type-performance Issue relates to performance or code size

Comments

@DartBot
Copy link

DartBot commented Mar 19, 2014

This issue was originally filed by @tatumizer


I will start submitting performance issues gradually, following reply from Srdjan and Peter.

calling 123456.toString() takes 28 nanoseconds (very good! improved by a factor of 3 in the last release!)
calling 123456.0.toString() takes 330 nanoseconds. In V8 javascript, same conversion takes 80 nanoseconds.

@DartBot
Copy link
Author

DartBot commented Mar 19, 2014

This comment was originally written by @tatumizer


probably, comparison above is not quite valid (in JS, ints are doubles and 123456.0 is the same as 123456), so it's better compare conversion of 12345.6 - then we have: in dart: 340 ns; in javascript: 270 ns.

@floitschG
Copy link
Contributor

It might be worth it to test if the double-input is an integer in a specific range to get the fast double->string for doubles with integer values.

The double->string library is pretty much the same in Dart and v8. It should be possible to optimize the 340ns.


Added Area-VM, Triaged labels.

@DartBot
Copy link
Author

DartBot commented Mar 19, 2014

This comment was originally written by @tatumizer


Tested java: it has special case for doubles with int values, too: converting 123456.1 takes 250 ns, but 123456.0 is faster: 150 ns. Tested on the same machine as dart, so the benchmarks are good for reference.

@DartBot
Copy link
Author

DartBot commented Mar 19, 2014

This comment was originally written by @tatumizer


Looks like current dart implementation of int.toString() is faster than java by 30-35%, and on par with best C++ ones.
It would be good to leverage this code while converting double (if possible).

@DartBot DartBot added Type-Defect area-vm Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends. labels Mar 19, 2014
@kevmoo kevmoo added type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) and removed priority-unassigned labels Feb 29, 2016
@zanderso zanderso added type-performance Issue relates to performance or code size and removed type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) labels Jun 23, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-vm Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends. type-performance Issue relates to performance or code size
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants