Skip to content

Improve consistency of data structure toText() functions #282

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rvanasa
Copy link
Collaborator

@rvanasa rvanasa commented Apr 10, 2025

Resolves #191.
Resolves #155 (indirectly).

@rvanasa rvanasa requested a review from a team as a code owner April 10, 2025 18:59
Copy link

✨ Documentation preview for bdbe66b:

https://dfinity.github.io/new-motoko-base/pull/282 (source code)

Copy link

Benchmark Results

bench/FromIters.bench.mo $({\color{gray}0\%})$

Benchmarking the fromIter functions

Columns describe the number of elements in the input iter.

Instructions: ${\color{gray}0\%}$
Heap: ${\color{gray}0\%}$
Stable Memory: ${\color{gray}0\%}$
Garbage Collection: ${\color{gray}0\%}$

Instructions

100 10_000 100_000
Array.fromIter 53_373 $({\color{gray}0\%})$ 5_152_334 $({\color{gray}0\%})$ 51_503_949 $({\color{gray}0\%})$
List.fromIter 35_436 $({\color{gray}0\%})$ 3_421_823 $({\color{gray}0\%})$ 34_204_824 $({\color{gray}0\%})$
List.fromIter . Iter.reverse 56_149 $({\color{gray}0\%})$ 5_392_962 $({\color{gray}0\%})$ 53_907_349 $({\color{gray}0\%})$

Heap

100 10_000 100_000
Array.fromIter 272 B $({\color{gray}0\%})$ 272 B $({\color{gray}0\%})$ 272 B $({\color{gray}0\%})$
List.fromIter 272 B $({\color{gray}0\%})$ 272 B $({\color{gray}0\%})$ 272 B $({\color{gray}0\%})$
List.fromIter . Iter.reverse 272 B $({\color{gray}0\%})$ 272 B $({\color{gray}0\%})$ 272 B $({\color{gray}0\%})$

Garbage Collection

100 10_000 100_000
Array.fromIter 2.76 KiB $({\color{gray}0\%})$ 234.79 KiB $({\color{gray}0\%})$ 2.29 MiB $({\color{gray}0\%})$
List.fromIter 3.51 KiB $({\color{gray}0\%})$ 312.88 KiB $({\color{gray}0\%})$ 3.05 MiB $({\color{gray}0\%})$
List.fromIter . Iter.reverse 5.11 KiB $({\color{gray}0\%})$ 469.17 KiB $({\color{gray}0\%})$ 4.58 MiB $({\color{gray}0\%})$
bench/PureListStackSafety.bench.mo $({\color{gray}0\%})$

List Stack safety

Check stack-safety of the following pure/List-related functions.

Instructions: ${\color{gray}0\%}$
Heap: ${\color{gray}0\%}$
Stable Memory: ${\color{gray}0\%}$
Garbage Collection: ${\color{gray}0\%}$

Instructions

pure/List.split 27_403_700 $({\color{gray}0\%})$
pure/List.all 9_301_156 $({\color{gray}0\%})$
pure/List.any 9_401_585 $({\color{gray}0\%})$
pure/List.map 26_005_117 $({\color{gray}0\%})$
pure/List.filter 24_305_592 $({\color{gray}0\%})$
pure/List.filterMap 30_606_216 $({\color{gray}0\%})$
pure/List.partition 24_706_539 $({\color{gray}0\%})$
pure/List.join 38_606_854 $({\color{gray}0\%})$
pure/List.flatten 29_607_262 $({\color{gray}0\%})$
pure/List.take 27_407_282 $({\color{gray}0\%})$
pure/List.drop 11_004_661 $({\color{gray}0\%})$
pure/List.foldRight 21_806_962 $({\color{gray}0\%})$
pure/List.merge 36_411_001 $({\color{gray}0\%})$
pure/List.chunks 61_513_741 $({\color{gray}0\%})$
pure/Queue 161_571_999 $({\color{gray}0\%})$

Heap

pure/List.split 272 B $({\color{gray}0\%})$
pure/List.all 272 B $({\color{gray}0\%})$
pure/List.any 272 B $({\color{gray}0\%})$
pure/List.map 272 B $({\color{gray}0\%})$
pure/List.filter 272 B $({\color{gray}0\%})$
pure/List.filterMap 272 B $({\color{gray}0\%})$
pure/List.partition 272 B $({\color{gray}0\%})$
pure/List.join 272 B $({\color{gray}0\%})$
pure/List.flatten 272 B $({\color{gray}0\%})$
pure/List.take 272 B $({\color{gray}0\%})$
pure/List.drop 272 B $({\color{gray}0\%})$
pure/List.foldRight 272 B $({\color{gray}0\%})$
pure/List.merge 272 B $({\color{gray}0\%})$
pure/List.chunks 272 B $({\color{gray}0\%})$
pure/Queue 272 B $({\color{gray}0\%})$

Garbage Collection

pure/List.split 3.05 MiB $({\color{gray}0\%})$
pure/List.all 328 B $({\color{gray}0\%})$
pure/List.any 328 B $({\color{gray}0\%})$
pure/List.map 3.05 MiB $({\color{gray}0\%})$
pure/List.filter 3.05 MiB $({\color{gray}0\%})$
pure/List.filterMap 3.05 MiB $({\color{gray}0\%})$
pure/List.partition 3.05 MiB $({\color{gray}0\%})$
pure/List.join 3.05 MiB $({\color{gray}0\%})$
pure/List.flatten 3.05 MiB $({\color{gray}0\%})$
pure/List.take 3.05 MiB $({\color{gray}0\%})$
pure/List.drop 328 B $({\color{gray}0\%})$
pure/List.foldRight 1.53 MiB $({\color{gray}0\%})$
pure/List.merge 4.58 MiB $({\color{gray}0\%})$
pure/List.chunks 7.63 MiB $({\color{gray}0\%})$
pure/Queue 18.31 MiB $({\color{gray}0\%})$

Note: Renamed benchmarks cannot be compared. Refer to the current baseline for manual comparison.

@crusso
Copy link
Contributor

crusso commented Apr 11, 2025

NB: we'll need to update the examples on the ai-doc branch...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

inconsistency: textual formats toText representation for Map
3 participants