Skip to content

perf(charts): code-unit ISO date scan in ChartData.parseTime (#1514) - #1604

Merged
ZhuchkaTriplesix merged 1 commit into
devfrom
issue/1514-chart-parse-time
Oct 15, 2026
Merged

ZhuchkaTriplesix merged 1 commit into
devfrom
issue/1514-chart-parse-time

Conversation

@ZhuchkaTriplesix

Copy link
Copy Markdown
Member

Summary

`ChartData.parseTime` is called for every cell of a candidate X column (up to 100,000 rows) when the Charts tab opens. Per cell it ran a regex, `replaceFirst(' ', 'T')` and up to seven `substring` + `int.parse` calls.

  • `_scanIso` checks `YYYY-MM-DD([T ]HH:MM(:SS(.f+)?)?)?(Z|[+-]HH:?MM)?` on code units and reports whether a zone ends the string (this replaces both `_isoTime` and `_hasZone`).
  • The year / month / day / hour / minute read-back (the guard against `2026-13-45` rolling over) uses `_digitsValue` instead of substrings.
  • `DateTime.tryParse` still decides validity, and gets the text as is: Dart's parser accepts a space between date and time, so `replaceFirst` was not needed.

Results are meant to be identical; the tests compare with the previous implementation.

Tests (not run locally; CI will)

`test/features/results/charts/chart_data_parse_time_test.dart` holds the old implementation as the reference and checks about 40 listed values (partial times, fractions, zones, a zone without a time, impossible dates, wrong separators, full-width digits), 6000 seeded random variations of a date string, and a 100,000-row column.

The "under 10 ms on 100,000 rows" acceptance item is not benchmarked here; the test only checks that the pass completes and gives the right answer.

Closes #1514

parseTime ran a regex, replaceFirst and up to seven substring + int.parse
calls per cell, for every cell of a candidate X column (up to 100,000 rows)
when the Charts tab opens.

The shape check is a small scanner over code units and the date / time fields
are read back with _digitsValue; DateTime.tryParse still decides validity and
takes the text as is (it accepts a space separator). A test compares the
result with the previous implementation on listed and random strings.

Closes #1514
@github-actions github-actions Bot added frontend Theme parser epic label: frontend performance Theme parser epic label: performance data-grid Interactive data grid, cell editor, filtering, groupings P2 Medium priority / Parity & Refactoring labels Oct 15, 2026
@github-actions github-actions Bot added this to the 0.5.0 milestone Oct 15, 2026
@ZhuchkaTriplesix
ZhuchkaTriplesix merged commit 98dec36 into dev Oct 15, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

data-grid Interactive data grid, cell editor, filtering, groupings frontend Theme parser epic label: frontend P2 Medium priority / Parity & Refactoring performance Theme parser epic label: performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant