diff options
| author | Mårten Nordheim <marten.nordheim@qt.io> | 2021-07-27 12:47:30 +0200 |
|---|---|---|
| committer | Mårten Nordheim <marten.nordheim@qt.io> | 2021-08-17 00:31:26 +0200 |
| commit | 2696d5a71b16e4288f4b071f9291cec7f719455a (patch) | |
| tree | 96dd72a80fcb651170e9c8456d50c7c762925891 /src/gui/platform/unix/qunixnativeinterface.cpp | |
| parent | fe9ddbe197d6ce4ff2634415c621c8fd9fe5810a (diff) | |
QString::number(double): Disentangle from the QLocale path
By writing code to do formatting without considering locale
The code tries to not do any unnecessary (re)allocations, and as such
it reserves at the beginning and only appends.
Cuts execution times of benchmarks by between 30% and 80%:
PASS : tst_QString::initTestCase()
PASS : tst_QString::number_double(0, format 'f', precision 0)
RESULT : tst_QString::number_double():"0, format 'f', precision 0":
- 0.0001774 msecs per iteration (total: 2,661, iterations: 15000000)
+ 0.0001238 msecs per iteration (total: 1,858, iterations: 15000000)
PASS : tst_QString::number_double(0, format 'f', precision 0)
RESULT : tst_QString::number_double():"0, format 'f', precision 0":
- 0.0002472 msecs per iteration (total: 3,709, iterations: 15000000)
+ 0.0001407 msecs per iteration (total: 2,111, iterations: 15000000)
PASS : tst_QString::number_double(0.12340, format 'f', precision 5)
RESULT : tst_QString::number_double():"0.12340, format 'f', precision 5":
- 0.0004769 msecs per iteration (total: 7,155, iterations: 15000000)
+ 0.0001638 msecs per iteration (total: 2,458, iterations: 15000000)
PASS : tst_QString::number_double(-0.12340, format 'f', precision 5)
RESULT : tst_QString::number_double():"-0.12340, format 'f', precision 5":
- 0.0005759 msecs per iteration (total: 8,639, iterations: 15000000)
+ 0.0001664 msecs per iteration (total: 2,497, iterations: 15000000)
PASS : tst_QString::number_double(1.618033988749895, format 'f', precision 15)
RESULT : tst_QString::number_double():"1.618033988749895, format 'f', precision 15":
- 0.0003644 msecs per iteration (total: 5,467, iterations: 15000000)
+ 0.0001869 msecs per iteration (total: 2,804, iterations: 15000000)
PASS : tst_QString::number_double(2.220446049e-16, format 'g', precision 10)
RESULT : tst_QString::number_double():"2.220446049e-16, format 'g', precision 10":
- 0.00070580 msecs per iteration (total: 10,587, iterations: 15000000)
+ 0.0002277 msecs per iteration (total: 3,416, iterations: 15000000)
PASS : tst_QString::number_double(1.0E-04, format 'E', precision 1)
RESULT : tst_QString::number_double():"1.0E-04, format 'E', precision 1":
- 0.00082213 msecs per iteration (total: 12,332, iterations: 15000000)
+ 0.0002018 msecs per iteration (total: 3,028, iterations: 15000000)
PASS : tst_QString::number_double(1.0E+08, format 'E', precision 1)
RESULT : tst_QString::number_double():"1.0E+08, format 'E', precision 1":
- 0.00082459 msecs per iteration (total: 12,369, iterations: 15000000)
+ 0.0002016 msecs per iteration (total: 3,025, iterations: 15000000)
PASS : tst_QString::number_double(-1.0E+08, format 'E', precision 1)
RESULT : tst_QString::number_double():"-1.0E+08, format 'E', precision 1":
- 0.00093840 msecs per iteration (total: 14,076, iterations: 15000000)
+ 0.0002074 msecs per iteration (total: 3,111, iterations: 15000000)
PASS : tst_QString::cleanupTestCase()
-Totals: 11 passed, 0 failed, 0 skipped, 0 blacklisted, 153777ms
+Totals: 11 passed, 0 failed, 0 skipped, 0 blacklisted, 48753ms
Task-number: QTBUG-88484
Change-Id: I23234467801243b163dff5cccf8a9fe9d90c3e2a
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src/gui/platform/unix/qunixnativeinterface.cpp')
0 files changed, 0 insertions, 0 deletions
