Thanks for your testing! The lag appears on my computer already with the patch i sent with the 1050 scalars. It shows when i open the patch, create any object, say a [float] and try to move it around.
With more scalars it can become even worse. You can test it with the attached patch. First select width and height and then click create. It creates a rectangle made of width x height one-pixel-scalars. With about 100 x 100 pixel, clearing the patch becomes increasingly slow. With 640 x 256 pixel, it took more than nine minutes on my computer to clear the subpatch or even to close the window, so be warned! ;) The reason for the lag is afaik, that all interface objects are constantly redrawn by Tcl, so it is not limited to scalars. best, ingo On 05/19/2018 11:23 PM, Roman Haefeli wrote: > On Sat, 2018-05-19 at 17:00 +0200, Ingo Stock wrote: >> On 05/19/2018 11:56 AM, Roman Haefeli wrote: >>> Yeah. It's not very elegant and gets expensive pretty quickly. I >>> was >>> wondering about alternative strategies, like moving non-used >>> scalars >>> out-of-the-way and later re-use them. It's cumbersome to implement, >>> but >>> probably less drastic than the clear-all-and-rebuild method. >> >> Can only answer to this: There are several methods to make scalars >> invisible. Anyhow, in my experience the method to clear the subpatch >> and >> recreate everything works quite well and is imho the clean approach >> to >> do it, as all the scalars are redrawn every frame any way. >> >> There are other limits to the use of data structures. Depending on >> your >> computer, when you get above 800 scalars or so, the patch becomes >> laggy. > > Thanks for your considerations. That is exactly the kind of info that I > was looking for. I don't share the experience with the limit of 800, > though, but this is presumably related to the computer/CPU. > >> Consider the attached patch: > > Nice and illustrative example patch. > >> On load 1050 scalars are created, which is >> already quite heavy on my computer. > > I'm not sure I understand correctly. Just having the patch open is > heavy on your box? Or interacting with it? > >> Anyhow, deleting a scalar by >> clicking on it works fine, using the clear and redraw method.>> > > It works fine for me, too. Then I measured the time it takes to redraw > different numbers of squares. It seems computation time is roughly > proportional to the number of redrawn objects (1: 0.08ms, 500: 3.9ms, > 1000: 7.6ms). So there is a penalty of this method with larger numbers > of scalars. > >> Hiding scalars by making them invisible doesn't help with the lagging >> problem. Therefore i would recommend the clear and redraw method any >> day. ;) > > I don't experience any lags by making specific scalars invisible. It > takes 0.007ms to make a single scalar invisible within a subpatch of > 1050 squares. See my modified version of your patch. > > Roman > > > > > > > > _______________________________________________ > [email protected] mailing list > UNSUBSCRIBE and account-management -> > https://lists.puredata.info/listinfo/pd-list >
#N canvas 275 264 835 329 10; #X floatatom 694 131 5 0 639 1 width #0-setWidth #0-width, f 5; #X floatatom 694 112 5 0 255 1 height #0-setHeight #0-height, f 5 ; #N canvas 68 127 697 295 \$0-pixelgrid 0; #X coords 0 255 640 0 640 255 2 0 0; #X restore 42 37 pd \$0-pixelgrid; #N canvas 584 116 613 300 \$0-pixel 0; #X obj 64 75 unpack s p f, f 13; #X floatatom 292 232 5 0 0 1 x - #0-x, f 5; #X floatatom 415 232 5 0 0 1 y - #0-y, f 5; #X obj 131 141 f; #X obj 186 141 f; #X floatatom 337 191 5 0 0 1 width #0-width -, f 5; #X floatatom 460 191 5 0 0 1 height #0-height -, f 5; #X obj 64 185 f; #X obj 64 163 t b b; #X obj 105 185 f; #X obj 292 188 max 0; #X obj 292 210 min; #X obj 415 188 max 0; #X obj 415 210 min; #X obj 64 53 struct \$0-pixel float x0 float y0 float x1 float y1; #X obj 64 207 set \$0-pixel x0 y0 x1 y1; #X obj 241 141 f; #X obj 296 141 f; #X obj 146 185 f; #X obj 187 185 f; #X obj 149 97 get \$0-pixel x0 y0 x1 y1; #X obj 64 97 sel change; #X obj 397 166 sel; #X obj 274 166 sel; #X obj 64 229 drawpolygon 919 1 x0 y0 x1 y1; #X obj 131 119 bang; #X connect 0 0 21 0; #X connect 0 1 15 4; #X connect 0 1 20 0; #X connect 3 0 7 1; #X connect 4 0 9 1; #X connect 5 0 11 1; #X connect 6 0 13 1; #X connect 7 0 15 0; #X connect 8 0 7 0; #X connect 8 1 9 0; #X connect 8 1 18 0; #X connect 8 1 19 0; #X connect 9 0 15 1; #X connect 10 0 11 0; #X connect 11 0 1 0; #X connect 12 0 13 0; #X connect 13 0 2 0; #X connect 14 0 0 0; #X connect 16 0 18 1; #X connect 16 0 23 1; #X connect 17 0 19 1; #X connect 17 0 22 1; #X connect 18 0 15 2; #X connect 19 0 15 3; #X connect 20 0 3 1; #X connect 20 1 4 1; #X connect 20 2 16 1; #X connect 20 2 23 0; #X connect 20 3 17 1; #X connect 20 3 22 0; #X connect 21 0 8 0; #X connect 21 1 25 0; #X connect 22 1 12 0; #X connect 23 1 10 0; #X connect 25 0 3 0; #X connect 25 0 4 0; #X connect 25 0 16 0; #X connect 25 0 17 0; #X restore 694 190 pd \$0-pixel; #X obj 694 275 outlet; #X obj 746 275 outlet; #X floatatom 694 256 5 0 0 1 x #0-x -, f 5; #X floatatom 746 256 5 0 0 1 y #0-y -, f 5; #N canvas 68 99 510 317 grid 0; #X obj 60 49 bng 15 250 50 0 empty \$0-new_grid new_grid 17 7 0 10 -262144 -1 -1; #X obj 60 179 f; #X msg 246 201 traverse \$1 \, bang; #X obj 246 223 pointer; #X floatatom 131 50 5 0 0 1 width #0-width -, f 5; #X floatatom 210 50 5 0 0 1 height #0-height -, f 5; #X obj 60 69 t b b b; #X msg 277 113 \; \$1 clear; #X obj 277 91 symbol pd-\$0-pixelgrid; #X obj 277 71 bng 15 250 50 0 empty \$0-clear_grid clear 17 7 0 10 -262144 -1 -1; #X obj 60 245 append \$0-pixel x0 y0 x1 y1; #X obj 60 201 t f f; #X obj 106 201 t f f; #X obj 199 223 + 1; #X obj 60 91 until; #X obj 60 113 t b b; #X obj 106 113 f; #X obj 138 113 + 1; #X obj 170 113 sel; #X obj 60 135 until; #X obj 60 157 t b b; #X obj 106 157 f; #X obj 138 157 + 1; #X obj 170 157 sel; #X msg 106 91 0; #X msg 106 135 0; #X obj 246 179 symbol pd-\$0-pixelgrid; #X connect 0 0 6 0; #X connect 1 0 11 0; #X connect 2 0 3 0; #X connect 3 0 10 4; #X connect 4 0 18 1; #X connect 5 0 23 1; #X connect 6 0 14 0; #X connect 6 1 26 0; #X connect 6 2 8 0; #X connect 6 2 24 0; #X connect 8 0 7 0; #X connect 9 0 8 0; #X connect 11 0 10 0; #X connect 11 1 10 2; #X connect 12 0 10 1; #X connect 12 1 13 0; #X connect 13 0 10 3; #X connect 14 0 15 0; #X connect 15 0 19 0; #X connect 15 1 16 0; #X connect 15 1 25 0; #X connect 16 0 17 0; #X connect 16 0 1 1; #X connect 16 0 18 0; #X connect 17 0 16 1; #X connect 18 0 14 1; #X connect 19 0 20 0; #X connect 20 0 1 0; #X connect 20 1 21 0; #X connect 21 0 22 0; #X connect 21 0 12 0; #X connect 21 0 23 0; #X connect 22 0 21 1; #X connect 23 0 19 1; #X connect 24 0 16 1; #X connect 25 0 21 1; #X connect 26 0 2 0; #X restore 694 212 pd grid; #X obj 694 150 bng 15 250 50 0 \$0-new_grid \$0-nor new_grid 17 7 0 10 -262144 -1 -1; #X obj 694 170 bng 15 250 50 0 \$0-clear_grid \$0-nor clear_grid 17 7 0 10 -262144 -1 -1; #X connect 6 0 4 0; #X connect 7 0 5 0;
signature.asc
Description: OpenPGP digital signature
_______________________________________________ [email protected] mailing list UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list
