method vs expanded list

Posted on
Sat Jan 20, 2018 4:21 pm
kw123 offline
User avatar
Posts: 8360
Joined: May 12, 2013
Location: Dallas, TX

method vs expanded list

An action xml currently has 0...29 of these:
Code: Select all
            <Field id ="type27"  type="menu" defaultValue="">
                <List class="self" filter="" method="filterDisplayType"  dynamicReload="false"/>
                <Label>ITEM     27:  .......................... select output type:</Label>
            </Field>
with
Code: Select all
    def filterDisplayType(self, filter="", valuesDict=None, typeId="", devId=""):
        list=[(u"0", u"not active")
             ,(u"text"          , u"text eg %%d:sensorVolt:input%%[mV]")
             ,(u"textWformat"   , u"text with format string eg %%v:123%%FORMAT%3.1f[mV]; only for numbers")
             ,(u"date"          , u"date  %Y-%m-%d full screen")
             ,(u"clock"         , u"clock %H:%H full screen")
             ,(u"dateString"    , u"date time, enter string format eg %HH:%M:%S")
             ,(u"line"          , u"line ")
             ,(u"point"         , u"point(s) ")
             ,(u"ellipse"       , u"ellipse define top left and bottom right points")
             ,(u"image"         , u"image file name ")
             ,(u"vBar"          , u"vertical bar ")
             ,(u"hBar"          , u"horizontal bar ")
             ,(u"vBarwBox"      , u"vertical bar  with box ")
             ,(u"hBarwBox"      , u"horizontal bar  with box")
             ,(u"rectangle"     , u"rectangle")
             ,(u"triangle"      , u"triangle")
             ,(u"hist"          , u"histogram ")
             ,(u"NOP"           , u"No operation, use to wait before next action")
             ,(u"exec"          , u"execute")]
        return list


the whole action xml is ~ 2500 lines long and it currently takes ~ 5 secs to load
Would it be faster if I replace the static method with an explicit list with the elements in "filterDisplayType" for all 29 fields?

I am trying to add 10 more and then the edit action times out.

Or I could go to "show one item only", but that would reduce the easiness of scrolling through all items, comparing values etc.

Karl

Posted on
Sat Jan 20, 2018 7:36 pm
Colorado4Wheeler offline
User avatar
Posts: 2794
Joined: Jul 20, 2009
Location: Colorado

Re: method vs expanded list

You don’t really do a lot of computing in the custom list function but if you have 29 call back functions I would think that’s a lot of overhead. I’ve run into that myself on custom lists. As a test you could create a new test device with that’s a copy of this one and make all those static and test and I’m betting it will be faster because sucking u an XML is a lot faster than calling functions.

My Modest Contributions to Indigo:

HomeKit Bridge | Device Extensions | Security Manager | LCD Creator | Room-O-Matic | Smart Dimmer | Scene Toggle | Powermiser | Homebridge Buddy

Check Them Out Here

Posted on
Sat Jan 20, 2018 10:18 pm
kw123 offline
User avatar
Posts: 8360
Joined: May 12, 2013
Location: Dallas, TX

Re: method vs expanded list

took me an hour .. and the result is:

calling simple static method
== open: 5-6 secs, save ~ 17 secs
included as list in the xml file:
== open 9-11 secs, save ~ 17 secs

The total action files are 283 Kbyte- method / 326KByte-included list (it has several actions),
Reducing it to only this action gets it from 283 down to 186KB and removing all leading banks in a line down to 150kByte.
But that does not seem to have an impact.

running the whole thing on the local server does not change the open, but the save is down from 17 secs to 1 secs.

Is there any other way to accelerate it?

Karl

Posted on
Sat Jan 20, 2018 11:55 pm
Colorado4Wheeler offline
User avatar
Posts: 2794
Joined: Jul 20, 2009
Location: Colorado

Re: method vs expanded list

I would have expected better results. Do you have auto refresh lists or anything like that?

My Modest Contributions to Indigo:

HomeKit Bridge | Device Extensions | Security Manager | LCD Creator | Room-O-Matic | Smart Dimmer | Scene Toggle | Powermiser | Homebridge Buddy

Check Them Out Here

Posted on
Sun Jan 21, 2018 8:41 am
kw123 offline
User avatar
Posts: 8360
Joined: May 12, 2013
Location: Dallas, TX

Re: method vs expanded list

All static lists no dynamic refresh


Sent from my iPhone using Tapatalk

Posted on
Sun Jan 21, 2018 12:34 pm
kw123 offline
User avatar
Posts: 8360
Joined: May 12, 2013
Location: Dallas, TX

Re: method vs expanded list

just some more info ..
cutting it down to 20 sections from 30
the edit open time goes from 5-6 secs to ~ 4 secs,

Posted on
Sun Jan 21, 2018 11:05 pm
kw123 offline
User avatar
Posts: 8360
Joined: May 12, 2013
Location: Dallas, TX

Re: method vs expanded list

have it now defined in windows of 10 sections
with a
"windowStart" text field ==> set the offset of the sections
"SetWindowStartID" button ==> copy from sequential props to window props
"saveWindowelements" button ==> copy from window props to sequential props


eg
SetWindowStartID copies existing props from ABC88 to ABCxYAYx8
and saveWindowelements copies ABCxYAYx8 to ABC8

where ABC is the property to be set and xYAYx is used as a separator in the split function

Then in save action all the propxxWindow get deleted and the propxx get error checked and saved

That has it down to 2 secs .. a little complicated but it works.

If someone is interested I attached the code
Karl

Code: Select all
####-------------------------------------------------------------------------####
    def setdisplayPropsWindowCALLBACKbutton(self, valuesDict=None, typeId="", devId=0):
        vd = valuesDict
        fromWindow = int(vd["fromWindow"])
        for xx in vd:
            if "xYAYx" in xx:
                yy = xx.split("xYAYx")
                if yy[1] == "99": continue
                fromProp =  yy[0]+unicode(int(yy[1])+fromWindow)
                if fromProp in vd:
                    vd[xx] = vd[fromProp]
        return vd
       
####-------------------------------------------------------------------------####
    def savedisplayPropsWindowCALLBACKbutton(self, valuesDict=None, typeId="", devId=0):
        vd = valuesDict
        fromWindow = int(vd["fromWindow"])
        for xx in vd:
            if "xYAYx" in xx:
                yy = xx.split("xYAYx")
                vd[ yy[0] + unicode(int(yy[1])+fromWindow) ] = vd[xx]
        return vd


and

Code: Select all
 
            <Field   id="start" type="label"><Label> enter line items ----------------------------------- </Label> </Field>
            <Field id="fromWindow"  type="menu" default="0" >
                <List>
                     <Option value= "0"  >0  .. 9</Option>
                     <Option value= "10" >10 .. 19</Option>
                     <Option value= "20" >20 .. 29</Option>
                     <Option value= "30" >30 .. 39</Option>
                     <Option value= "40" >40 .. 49</Option>
                     <Option value= "50" >50 .. 59</Option>
                     <Option value= "60" >60 .. 69</Option>
                     <Option value= "70" >70 .. 79</Option>
               </List>
                <Label>define elements edit window:</Label>
            </Field>
            <Field  id="setdisplayPropsWindow" type="button"   >
                <Label> ....after selection click</Label><Title>set Window</Title> <CallbackMethod>setdisplayPropsWindowCALLBACKbutton</CallbackMethod>
            </Field>

## elements go here eg for section # 8 and element/props  "offONTime"
            <Field id="offONTimexYAYx8"  type="textfield" default="0,9999999,0" visibleBindingId="typexYAYx8"  visibleBindingValue="text,textWformat,dateString,NOP,date,clock,line,vBar,hBar,vBarwBox,hBarwBox,point,ellipse,image,hist,rectangle,triangle,dot">
                <Label>seconds off,on,off eg 5,3,2:</Label>
            </Field>


            <Field  id="savedisplayPropsWindow" type="button"   >
                <Label> ....after finishing edit elements click</Label><Title>save Window data</Title> <CallbackMethod>savedisplayPropsWindowCALLBACKbutton</CallbackMethod>
            </Field>

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest