Android Question CustomListView Efficiency Release/Debug

fbritop

Active Member
Licensed User
Longtime User
I have a CLV that reads almost 280 records from a SQLDB. It then creates each panel for each record on the CLV with the .add(panel) method.

One wierd thing that is happening is that code execution takes a whole lot less in DEBUG MODE than what it takes on RELEASE MODE. I have done 2 tests for each mode. RELEASE averages almost 15 seconds for the panel insert. DEBUG takes arround 3.5secs. Cannot seem to find why this happends. RELEASE should be faster than DEBUG or not?

B4X:
Dim startTime As Long=DateTime.now
For i=0 To inmuebles.Size-1
    Dim InmuebleMap As Map=(inmuebles.Get(i))
    InmuebleMap.Put("typeInmuebleGlobal", map2.Get("typeInmueble"))
    typeInmuebleGlobal= map2.Get("typeInmueble")
    Dim insertMap As Map
    insertMap.Initialize
    insertMap.Put("hashInmueble", InmuebleMap.Get("hashInmueble"))
    insertMap.Put("typeInmueble", InmuebleMap.Get("typeInmueble"))
    insertMap.Put("inmueble", InmuebleMap.Get("inmueble"))
    listOfInmuebles.Add(insertMap)
Next
Log("FINISH SQL MAP BUILD:" & (DateTime.Now-startTime))
If listInmuebles.AsView.Visible=True Then
    DBUtils.InsertMaps(x.SQLDB, "inmuebles", listOfInmuebles)
   
    Log("FINISH INSERT SQL Statements:" & (DateTime.Now-startTime))
    Dim c1 As Cursor
    c1=x.SQLDB.ExecQuery("select * from inmuebles")
    Dim maxRecords As Int=34
    If c1.RowCount<maxRecords Then maxRecords=c1.RowCount
    For i=0 To c1.RowCount-1 'maxRecords
        c1.Position=i
        Dim InmuebleMap As Map
        InmuebleMap.Initialize
        InmuebleMap=x.Cursor2Map(c1)
        InmuebleMap.Put("typeInmuebleGlobal", typeInmuebleGlobal)
        listInmuebles.Add(createInmueble(InmuebleMap), 60dip, InmuebleMap)
        'Sleep(0)
    Next                       
    listInmuebles.JumpToItem(0)
End If
Log("FINISH CREATING PANELS:" & (DateTime.Now-startTime))

Test Results:

-DEBUG MODE-TEST #1
List Size:276
FINISH SQL MAP BUILD:3
FINISH INSERT SQL Statements:32
FINISH CREATING PANELS:3284

-DEBUG MODE-TEST #2
List Size:276
FINISH SQL MAP BUILD:3
FINISH INSERT SQL Statements:28
FINISH CREATING PANELS:3299


-RELEASE MODE-TEST #1
List Size:276
FINISH SQL MAP BUILD:3
FINISH INSERT SQL Statements:180
FINISH CREATING PANELS:14986

-RELEASE MODE-TEST #2
List Size:276
FINISH SQL MAP BUILD:4
FINISH INSERT SQL Statements:34
FINISH CREATING PANELS:14834
 

fbritop

Active Member
Licensed User
Longtime User
Yes, we load a bitmap, but I tested without the bitmap with the same results:

B4X:
Sub createInmueble(m As Map) As Panel
    Dim p As Panel
    p.Initialize("inmueble")
    p.Color=Colors.White
    'Dim im As ImageView
    'im.Initialize("")
    'p.AddView(im, 5dip, 5dip, 50dip, 50dip)
    'If File.Exists(File.DirAssets, "inmueble." & m.Get("typeInmueble") & ".png") Then
    '    im.Bitmap=LoadBitmap(File.DirAssets, "inmueble." & m.Get("typeInmueble") & ".png")
    'Else
    '    im.Bitmap=LoadBitmap(File.DirAssets, "inmueble.estacionamiento.png")
    'End If
    'im.Gravity=Gravity.FILL
   
    Dim l As Label
    l.Initialize("")
    p.AddView(l, 60dip, 5dip, pnlInmueble.Width-70dip, 25dip)
    l.Text=m.Get("typeInmueble") & ":"
    l.Typeface=x.fontBold
   
    Dim l2 As Label
    l2.Initialize("")
    p.AddView(l2, 60dip, 20dip, pnlInmueble.Width-70dip, 25dip)
    l2.Text=m.Get("typeInmuebleGlobal") & " " & m.Get("inmueble")
    l.Typeface=x.fontNormal
   
    l.TextSize=sm.GetSetting("subTitleSize")
    l.Typeface=x.fontBold
   
    l2.TextSize=sm.GetSetting("titleSize")
   
    Dim line As Label
    line.Initialize("")
    p.AddView(line, 0, 0, pnlInmueble.Width, 1dip)
    line.Color=Colors.RGB(235,235,235)
   
    m.Put("rutComunidad", txtRUT.Text)
    p.Tag=m
   
    Return p
End Sub
 
Upvote 0
Top