Commit Graph

1981 Commits

Author SHA1 Message Date
Jonathan Daugherty
1059545149 addTableBorders: greatly simplify the implementation and let joinable borders do more of the work 2022-12-27 14:05:52 -08:00
Jonathan Daugherty
36652fde57 addTableBorders: use a single row or column border rather than border segments when possible 2022-12-27 13:58:06 -08:00
Jonathan Daugherty
4461c9645c RenderedTableCells: carry cell renderings in row-major order rather than column-major order 2022-12-27 13:51:18 -08:00
Jonathan Daugherty
871d383467 Table: break up renderTable into its internal phases, cell layout and border augmentation 2022-12-27 13:38:07 -08:00
Jonathan Daugherty
4490762640 guide: edits 2022-12-24 16:33:56 -08:00
Jonathan Daugherty
0321224a87 README: edit 2022-12-24 16:28:26 -08:00
Jonathan Daugherty
a9aad124e9
Merge pull request #418 from srhoulam/add-haradict
Add haradict to applications using brick.
2022-12-16 23:25:10 -08:00
Saad Rhoulam
eb8cead472 Add haradict to applications using brick. 2022-12-17 00:25:10 -05:00
Jonathan Daugherty
42bb0d082b Update project list 2022-12-13 22:30:54 -08:00
Jonathan Daugherty
3cba1e4fd4
Merge pull request #416 from srhoulam/add-babel-cards
Add babel-cards to applications using brick.
2022-12-06 10:03:33 -08:00
Saad Rhoulam
47b74c3362 Add babel-cards to applications using brick. 2022-12-06 12:40:28 -05:00
Jonathan Daugherty
33f94b4681
Merge pull request #415 from BlastWind/patch-1
Added haskell tic-tac-toe
2022-12-02 12:45:26 -08:00
Andrew Chen
236a41e0dd
Added haskell tic-tac-toe 2022-12-02 14:15:33 -05:00
Jonathan Daugherty
ff17667264 EditorLineNumbersDemo: add conditional import 2022-11-25 10:10:47 -08:00
Jonathan Daugherty
fda7e084b2 Add editor line number demo program 2022-11-25 09:57:20 -08:00
Jonathan Daugherty
ba477ef1c4 Bump version, update changelog 2022-11-24 10:20:27 -08:00
Jonathan Daugherty
72fdcd8204 Dialog: clarify modal usage assumption 2022-11-24 09:59:27 -08:00
Jonathan Daugherty
56fb5e3526 Dialog: some haddock edits 2022-11-22 15:51:16 -08:00
Jonathan Daugherty
43ab5d5c3a Dialog: take resource names for buttons to allow cursor placement and click event support 2022-11-22 15:48:55 -08:00
Jonathan Daugherty
ac50115cc2 Bump version, update changelog 2022-10-22 20:05:35 -07:00
Jonathan Daugherty
4b94bf2fe5 Border: add conditional Monoid import 2022-10-22 20:04:44 -07:00
Jonathan Daugherty
6b73d78783 Brick.Widgets.Border: add hBorderAttr, vBorderAttr for hBorder/vBorder respectively (see also #404) 2022-10-22 19:56:22 -07:00
Jonathan Daugherty
5cb0424dfe Core: use TextWidth instance rather than re-implementing it 2022-10-16 18:12:26 -07:00
Jonathan Daugherty
dde5d6b60b Core: rewrite "str" in terms of the new "txt" implementation 2022-10-16 18:11:19 -07:00
Jonathan Daugherty
2064f1d524
Merge pull request #403 from frasertweedale/perf/txt
txt: use Data.Text.Text based implementation
2022-10-16 17:24:48 -07:00
Fraser Tweedale
9a54ec16c6 txt: use Data.Text.Text based implementation
Use `Data.Text.Text` to improve the performance of the `txt` widget.

On my workload that makes heavy use of `txt` this substantially
reduces allocation and somewhat reduces CPU time.  Total
CPU/allocation and top cost centres follow.

Before:

```
total time  =        0.62 secs   (623 ticks @ 1000 us, 1 processor)
total alloc = 769,766,368 bytes  (excludes profiling overheads)

COST CENTRE         MODULE                               SRC                                                  %time %alloc

str                 Brick.Widgets.Core                   src/Brick/Widgets/Core.hs:(341,1)-(356,70)            32.4   38.7
safeWcswidth        Graphics.Text.Width                  src/Graphics/Text/Width.hs:54:1-51                     9.3    3.1
safeWcwidth         Graphics.Text.Width                  src/Graphics/Text/Width.hs:49:1-29                     5.8    6.2
vBox                Brick.Widgets.Core                   src/Brick/Widgets/Core.hs:(481,1)-(483,41)             5.6   11.3
txt                 Brick.Widgets.Core                   src/Brick/Widgets/Core.hs:367:1-20                     4.5   14.2
…
```

After:

```
total time  =        0.54 secs   (542 ticks @ 1000 us, 1 processor)
total alloc = 432,922,048 bytes  (excludes profiling overheads)

COST CENTRE         MODULE                               SRC                                                  %time %alloc

safeWctwidth        Graphics.Text.Width                  src/Graphics/Text/Width.hs:59:1-53                    14.8   10.9
txt                 Brick.Widgets.Core                   src/Brick/Widgets/Core.hs:(367,1)-(381,63)            14.6   10.8
safeWcwidth         Graphics.Text.Width                  src/Graphics/Text/Width.hs:49:1-29                    10.9   11.0
vBox                Brick.Widgets.Core                   src/Brick/Widgets/Core.hs:(514,1)-(516,41)             9.0   20.1
cropResultToContext Brick.Widgets.Internal               src/Brick/Widgets/Internal.hs:(82,1)-(87,47)           4.6    3.8
…
```
2022-10-16 17:31:05 +10:00
Jonathan Daugherty
29377b705a BoxRenderer: remove defunct limitSecondary field 2022-10-15 09:21:07 -07:00
Jonathan Daugherty
b0ebc63e7a
Merge pull request #402 from frasertweedale/perf/renderBox-redundant-crops
renderBox: avoid redundant cropResultToContext calls
2022-10-15 09:13:05 -07:00
Fraser Tweedale
386aedadc0 renderBox: avoid redundant cropResultToContext calls
In profiling output I noticed that `renderBox` crops the child widgets
three times.  For example:

```
                                       individual      inherited
                            entries  %time %alloc   %time %alloc

vLimit                        32637    1.4    1.5    10.4   11.5
 cropResultToContext          32637    0.4    1.5     1.4    2.6
  crop                        32637    0.9    1.0     0.9    1.0
   setCoordinates             32637    0.0    0.0     0.0    0.0
  crop                        32637    0.0    0.1     0.2    0.1
   cropBottom                 32637    0.2    0.0     0.2    0.0
    imageHeight               32637    0.0    0.0     0.0    0.0
   cropRight                  32637    0.0    0.0     0.0    0.0
    imageWidth                32637    0.0    0.0     0.0    0.0
  availHeight                 32626    0.0    0.0     0.0    0.0
 hLimit                           0    0.9    1.3     7.5    7.5
  cropResultToContext         65274    2.0    2.9     5.9    5.2
 …
```

Note the calls to `cropResultToContext`.  It is called once for each
call to the enclosing `vLimit`, and a further two times in the inner
`hLimit` call.  In the implementation, that pattern that causes this is:

```haskell
render $ limitPrimary br remainingPrimary
       $ limitSecondary br availSecondary
       $ cropToContext widget
```

`limitPrimary` and `limitSecondary` are `vLimit` and `hLimit` or
vice-versa, depending on whether we are rendering a `vBox` or `hBox`.
Both `vLimit` and `hLimit` modify the available space in the render
context and call `cropToContext`, so the explicit `cropToContext` is
redundant.  The `limitSecondary` is also redundant, because
`availSecondary` is taken directly from the render context.  So, remove
the redundant operations.

As a result of this change, total program allocation, and allocation for
the `vBox` cost centre that is the parent of the cost centres table
shown above, improve from:

```
total time  =        0.61 secs   (614 ticks @ 1000 us, 1 processor)
total alloc = 856,554,568 bytes  (excludes profiling overheads)

                                 individual      inherited
                      entries  %time %alloc   %time %alloc

vBox                        0    5.0    9.0    23.9   25.9
```

to

```
total time  =        0.61 secs   (606 ticks @ 1000 us, 1 processor)
total alloc = 773,138,088 bytes  (excludes profiling overheads)

                                 individual      inherited
                      entries  %time %alloc   %time %alloc

vBox                        0    5.3    8.9    19.0   19.9
```

Exactly the same number of `vLimit` calls occurs; this is the profiling
caused by navigating around a specific, large mail message in Purebred.
Total program CPU time and allocation have non-deterministic factors, so
take them with a grain of salt.

Allocations in `renderBox` are reduced significantly for long lists of
widgets.  In my scenario (rendering and navigating around a long email
in Purebred), this changes eliminates ~10% of all program allocation.

Surprisingly, although the cost centres report lower CPU time, the total
program CPU time did not change significantly.  I don't have a theory to
explain this.
2022-10-16 01:19:18 +10:00
Jonathan Daugherty
99d41c28fd
Merge pull request #401 from kquick/attrdoc_ref_fixes 2022-10-12 16:22:47 -07:00
Kevin Quick
15c783ed47
Fix attr haddocks to show actual code and not references. 2022-10-12 16:19:25 -07:00
Jonathan Daugherty
1bf099f69f
Merge pull request #399 from kquick/add_brick_panes_mywork
Add brick-panes and mywork projects.
2022-10-06 09:15:58 -07:00
Kevin Quick
2692684042
Add brick-panes and mywork projects. 2022-10-06 09:12:22 -07:00
Jonathan Daugherty
f6ae8b71b8 Merge branch 'master' of github.com:jtdaugherty/brick 2022-10-03 12:24:01 -07:00
Jonathan Daugherty
982f3070b0 CHANGELOG: typo 2022-10-03 12:23:51 -07:00
Jonathan Daugherty
25bf04f1ed Bump version, update changelog 2022-09-29 19:57:08 -07:00
Jonathan Daugherty
fdd40dad57
Merge pull request #398 from frasertweedale/perf/renderBox
renderBox: performance improvements
2022-09-29 19:50:32 -07:00
Fraser Tweedale
c3e1ac8bfd renderBox: avoid O(n²) slowdowns
`renderBox` computes translations by summing the primary dimensions
of widgets preceding the current widget.  This has O(n²) complexity
and causes poor performance with long lists of widgets.  In one
purebred scenario `renderBox` contributes ~30% of the CPU time of
the program.

Use a State computation to accumulate the total offset during the
traversal.  In the scenario described above, this change caused
`renderBox` to drop to ~4% of the program CPU time.

Also remove an occurence of `sum` that calculateed the remaining
primary dimension space after rendering of greedy widgets.  We
already calculate this value during the greedy widget render
traversal, so reuse it.
2022-09-30 10:46:12 +10:00
Fraser Tweedale
35874d5b82 renderBox: use strict state monad
Using the strict state monad to calculate `renderedHis` brings
another small performance increase.

I find the StateT version a little easier to comprehend too,
although it's a subjective matter.
2022-09-29 23:11:34 +10:00
Fraser Tweedale
2b97d32db5 renderBox: avoid unnecessary use of dlist
`renderBox` uses dlist to grow the result list while doing a render
traversal.  An ordinary fmap'd list construction suffices and offers
a very small but measurable performance boost.

Furthermore this is the only place the *dlist* library was used so
*brick* no longer depends on it.
2022-09-29 23:11:20 +10:00
Jonathan Daugherty
3417a47413 Bump version, update changelog 2022-09-27 08:51:26 -07:00
Jonathan Daugherty
1c237ef1e7
Merge pull request #395 from jhrcek/jan/hlint-fixes 2022-09-24 07:35:08 -07:00
Jan Hrček
3bd2235c0c Fix some hlint warnings 2022-09-24 12:56:11 +02:00
Jonathan Daugherty
a9fd2f15d1
Merge pull request #394 from jhrcek/jhrcek/haddock-update 2022-09-22 07:30:31 -07:00
Jan Hrček
fe7ce8f9a6 Fix haddock examples 2022-09-22 13:04:21 +02:00
Jonathan Daugherty
a117ff7790 Whitespace 2022-09-21 13:50:39 -07:00
Jonathan Daugherty
5ebe98eac6 brick-theme-demo: nit 2022-09-21 13:48:18 -07:00
Jonathan Daugherty
5fe19ab046 brick-fill-demo: improve UI 2022-09-21 13:46:40 -07:00
Jonathan Daugherty
c527366347
Merge pull request #392 from jhrcek/jhrcek/typos 2022-09-21 08:48:10 -07:00
Jan Hrček
ab70e82301 Fix typos 2022-09-21 17:40:54 +02:00