iOS Question B4I performance

GiulioVale

Active Member
Licensed User
Longtime User
How is possible that debug app is more fast then release app ?
In my project there are Custolistview and Sql and I find that app in debug mode is more fast than in release mode.
 

GiulioVale

Active Member
Licensed User
Longtime User
Release mode should be faster than debug mode.

The only difference might be with file handling. However you need to provide more information. What exactly is your app doing and which part is slower?
Find some value inside a table and populate a customlistview. Same table and same query for release and debug mode.
Slow time is for customlistview.
Any possibility that in debug mode the app use less "asynchronously" solution?
 
Upvote 0

GiulioVale

Active Member
Licensed User
Longtime User
CustomListView population.
For 250 items debug is immediate, release require around 5 seconds.
btw: query time is the same. Populate the list freeze the interface.
 
Upvote 0

GiulioVale

Active Member
Licensed User
Longtime User
Hi Erel I modify your CustomListView example to show the problem.
Every list have 250 items.
With clear you can clear the list and with other two button you can populate list1 cvl1 and cvl2.
In debug mode you can see that after click on Populate list you can scroll the list immediatly in release mode no

giulio
 

Attachments

  • ListSlow.zip
    3.7 KB · Views: 176
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Thank you!

I found the bug and fixed it. It was a bug in iCore library.
The updated library was uploaded to the hosted builders.

The updated library will be included in the next update. If you are using a local builder you can download it now from here: www.b4x.com/b4i/files/iCore.zip (only the a file is important, copy it to the Mac Libs folder).
 
Upvote 0

drponciano

Member
Licensed User
Longtime User
Hello: I have an interesting question about performance. I’m translating a program written in B4A for presenting signals in realtime on screen. The program works very well even in the slowest and oldest android phones. I started working in B4i and found that the same code works in my Iphone 5s but, when executing in iphone 5c and ipod 5, the program has no time to display the signals. I have some 10 floating point calculations for 8 channels 250 times per second. When I don’t do them the program seems to work fine. What am I doing wrong? I don’t think the processor on those devices is that SLOW, is it?.
 
Upvote 0

drponciano

Member
Licensed User
Longtime User
This is the code:
B4X:
Private Sub unarrollo_NewData (buflocal() As Byte)
            Dim count As Int
            Dim iii,jjj,punto,elcanal As Int
            Dim canal(8) As Short
            Dim Balto,Bbajo AsShort     
            Dim encontrado As Boolean
            Dim pini,posi_inicio As Int
            Dim dato As Double
            Dim abit,bbit,cbit As Short


            count=buflocal.Length
            recibidos=recibidos+count
            npaquetes=npaquetes+1

         

            If count>3 Then

                encontrado=False
                pini=0         
                posi_inicio=-1
                Do While encontrado=False
                    abit=Bit.AND(buflocal(pini),0xFF)
                    bbit=Bit.AND(buflocal(pini+1),0xFF)
                    cbit=Bit.AND(buflocal(pini+2),0xFF)
                    If (abit=0xFF) AND (bbit=0xFF) AND (cbit=0x0F) Then
                        posi_inicio=pini
                        encontrado=True
                        End If
                    pini=pini+1
                    If pini>count-6 Then encontrado=True
                    Loop  
                End If
             
            Dim npbufer As Int
         
            npbufer=(count-posi_inicio)             
            npbufer=(npbufer/21)-1                  
   
        
            If (posi_inicio>=0) AND (npbufer>0) Then
                ' Hay un nuevo grupo de derivaciones
         
                'If npbufer<=0 Then Return
                posi_inicio=posi_inicio+5
                For iii=0 To npbufer     
                   punto=iii*21
                    ' DoEvents
                    For jjj=0To7   
                        elcanal=jjj*2
                        Balto=Bit.AND(buflocal(posi_inicio+punto+elcanal),0xFF)   
                        Bbajo=Bit.AND(buflocal(posi_inicio+1+punto+elcanal),0xFF)
                        Balto=Bit.ShiftLeft(Balto,8)
                        canal(jjj)= Bit.OR(Balto,Bbajo)
                        Next               
                 
    
                    npecg=npecg+1
                    npuntostotales=npuntostotales+1
                 
                    Ifnpecg>=npuntosecgThennpecg=0
                 
                    ecg(0,npecg)=canal(1)                             
                    ecg(1,npecg)=canal(2)                              
                    ecg(2,npecg)=ecg(1,npecg)-ecg(0,npecg)     
                 
                    ecg(3,npecg)=-(ecg(0,npecg)+ecg(1,npecg))/2 
                    ecg(4,npecg)=(ecg(0,npecg)-ecg(2,npecg))/2
                    ecg(5,npecg)=(ecg(1,npecg)+ecg(0,npecg))/2 
                 
                    ecg(6,npecg)=canal(7)                            
                    ecg(7,npecg)=canal(3)                             
                    ecg(8,npecg)=canal(4)                          
                    ecg(9,npecg)=canal(5)                              
                    ecg(10,npecg)=canal(6)                             
                 
‘’ This is the code that, if removed, makes that app work fast

                    ganancia = 1.001701595e+00

                      For jjj=0 To ncanales-1
                            xv(jjj,0)= xv(jjj,1)
                            xv(jjj,1)= xv(jjj,2)
                            xv(jjj,2)= xv(jjj,3)
                            xv(jjj,3)= xv(jjj,4)
                          xv(jjj,4)=ecg(jjj,npecg)/ganancia

                          yv(jjj,0)= yv(jjj,1)
                            yv(jjj,1)= yv(jjj,2)
                            yv(jjj,2)= yv(jjj,3)
                            yv(jjj,3)= yv(jjj,4)

                           yv(jjj,4)=(xv(jjj,0)+xv(jjj,4))-4*(xv(jjj,1)+xv(jjj,3))+6*xv(jjj,2)+ _
                                        (-0.9966061611*yv(jjj,0))+(3.9898113460*yv(jjj,1))+ _
                                        (-5.9898042025*yv(jjj,2))+(3.9965990176*yv(jjj,3))
                    
                         
                            ecg(jjj,npecg)=(yv(jjj,4)) ' /divisory)
                            Next' jjj del filtro digital


                   If filtrado Then
                      ganancia=6.880159536e+01
                      For jjj=0 To ncanales-1
                         xxv(jjj,0)= xxv(jjj,1)
                            xxv(jjj,1)= xxv(jjj,2)
                            xxv(jjj,2)= xxv(jjj,3)
                            xxv(jjj,3)= xxv(jjj,4)
                         xxv(jjj,4)=ecg(jjj,npecg)/ganancia

                         yyv(jjj,0)= yyv(jjj,1)
                            yyv(jjj,1)= yyv(jjj,2)
                            yyv(jjj,2)= yyv(jjj,3)
                            yyv(jjj,3)= yyv(jjj,4)

                         yyv(jjj,4)=(xxv(jjj,0) + xxv(jjj,4)) + 4 * (xxv(jjj,1) + xxv(jjj,3)) + 6 * xxv(jjj,2)+ _
                                         ( -0.3042874459 * yyv(jjj,0)) + (  1.2113918802 * yyv(jjj,1))+ _
                                         ( -2.1702818344 * yyv(jjj,2)) + (  2.0306246530 * yyv(jjj,3))
                                               
                         ecg(jjj,npecg)=(yyv(jjj,4))
                         Next' { del For del filtrado digital }
                      EndIf' de filtrado pasa bajas                  
                    
          
                    IfTrueThen' modulo(npecg,pasox)=0 Then
                        ' xx = xx + dx
                        xant=xx
                        ii=ii+1
                        xx = (Div*ii)/50            ' 50 muestras de ECG corresponden a un cuadro de 5 mm (250 muest=25 mm)
                        If xx>GridW Then
                         
                            EraseCurves
                            xx = 0
                            ii=0
                            xant=0
                            GetValues                         
                            DrawCurves
                            Return                         
                            End If
                        GetValues
                        DrawCurves
                        End If                     

                    Next                    ' iii   Siguiente punto del ECG
                If modulo(npecg,100)=0 Then let_paciente.Text="NE:"&NumberFormat(npecg,0,0)
                EndIf                    ' Posi_inicio         
    End Sub' Llegaron bytes del ZiECG
[\code]
 
Upvote 0

drponciano

Member
Licensed User
Longtime User
Hi Erel. Here you will find the project. In line 128 you’ll find the IP address for the server who sends data (you should change for your net). Lines 427-472 contain the offending code. The simulation.exe and simula.txt contain the simulator waiting for a connection on port 2000. The IOS program tries to connect to the server with a TCP socket on port 2000 after you push the connect button. In ipod and iphone 5c the program slows to a stop after you push the filter button enabling the digital filtering. Thanks.
 

Attachments

  • Performance.zip
    339.1 KB · Views: 204
Upvote 0
Top