如何提高iOS应用程序的性能?

时间:2021-09-25 06:14:14

I have developed an application which works on iPhone-3GS, iPhone-4, iPhone-4S.

我开发了一个适用于iPhone-3GS,iPhone-4,iPhone-4S的应用程序。

For start up process, it take 30 seconds on iPhone-4s , and take 50-55 seconds on iPhone-3gs. Tested on same network.(Its not an issue related to network or internet; In simulator it took only 5 second.)

对于启动过程,在iPhone-4上需要30秒,在iPhone-3gs上需要50-55秒。在同一网络上测试。(它不是与网络或互联网相关的问题;在模拟器中只用了5秒钟。)

In this start up process, App performs several actions like deletion of old data from Database, WebService calling and inserting response data into Database. Application calls almost 8 web service on main thread using performSelectorOnMainThread method(sequentially).

在此启动过程中,App执行多项操作,例如从数据库中删除旧数据,调用WebService并将响应数据插入到数据库中。应用程序使用performSelectorOnMainThread方法(顺序)在主线程上调用近8个Web服务。

I am using SQLite and Compiled Query structure for insertion. I want to improve performance of application and want to reduce start up time taken by application.

我使用SQLite和Compiled Query结构进行插入。我想提高应用程序的性能,并希望减少应用程序的启动时间。

Same back-end is used by Android team and they are also doing same thing. It takes 20 sec only on Galaxy note (Team android is using Object Relational Modal to communicate with Sqlite database ).

Android团队使用相同的后端,他们也在做同样的事情。仅在Galaxy note上需要20秒(Team android正在使用Object Relational Modal与Sqlite数据库进行通信)。

Is this the reason for faster performance ?

这是性能更快的原因吗?

Is there anything that work same as ORM in Java for Objective-C to improve performance while dealing with Sqlite (processor specific , less time consuming)?

是否有任何与Java中的ORM相同的Objective-C可以在处理Sqlite时提高性能(特定于处理器,耗时较少)?

3 个解决方案

#1


1  

First thing is you should not be doing network operations (web service calls) on the main thread. That should be done on background threads. I don't know enough about using SQLite directly but with CoreData you can make "database" updates on background threads and just use the main thread for merging the two ManagedObjectContexts.

首先,您不应该在主线程上进行网络操作(Web服务调用)。这应该在后台线程上完成。我不太了解直接使用SQLite但是使用CoreData可以在后台线程上进行“数据库”更新,只需使用主线程来合并两个ManagedObjectContexts。

I imagine moving your WS calls to background threads (AFNetworking is a great framework btw), that you will see lots of improvement.

我想把你的WS调用移到后台线程(AFNetworking是一个很好的框架顺便说一句),你会看到很多改进。

One example I have is a web-service based app that gets 7000 records from a SQL Server DB and creates an NSArray (data comes in as JSON) and that process takes 7-10 seconds. I further minimize the impact on the user by doing my auto-authentication process at the same time.

我的一个例子是基于Web服务的应用程序,它从SQL Server数据库获取7000条记录并创建一个NSArray(数据以JSON形式出现),该过程需要7-10秒。我通过同时执行自动身份验证过程进一步减少了对用户的影响。

30 seconds is too long to have the user wait on something IMO.

30秒太长时间让用户等待IMO。

#2


1  

You can use below link for fast insertion of data. We used it for saving 50000 records which done in few sec which was done in minutes

您可以使用以下链接快速插入数据。我们使用它来保存50000条记录,这些记录在几秒钟内完成,这些记录在几分钟内完成

Fast Insertion in database

快速插入数据库

#3


1  

14 best tips are available here Best Steps to increase performance of iOS App

这里提供了14个最佳技巧提高iOS App性能的最佳步骤

In this tutorial, point 13 gives the info you required.

在本教程中,第13点提供了您需要的信息。

#1


1  

First thing is you should not be doing network operations (web service calls) on the main thread. That should be done on background threads. I don't know enough about using SQLite directly but with CoreData you can make "database" updates on background threads and just use the main thread for merging the two ManagedObjectContexts.

首先,您不应该在主线程上进行网络操作(Web服务调用)。这应该在后台线程上完成。我不太了解直接使用SQLite但是使用CoreData可以在后台线程上进行“数据库”更新,只需使用主线程来合并两个ManagedObjectContexts。

I imagine moving your WS calls to background threads (AFNetworking is a great framework btw), that you will see lots of improvement.

我想把你的WS调用移到后台线程(AFNetworking是一个很好的框架顺便说一句),你会看到很多改进。

One example I have is a web-service based app that gets 7000 records from a SQL Server DB and creates an NSArray (data comes in as JSON) and that process takes 7-10 seconds. I further minimize the impact on the user by doing my auto-authentication process at the same time.

我的一个例子是基于Web服务的应用程序,它从SQL Server数据库获取7000条记录并创建一个NSArray(数据以JSON形式出现),该过程需要7-10秒。我通过同时执行自动身份验证过程进一步减少了对用户的影响。

30 seconds is too long to have the user wait on something IMO.

30秒太长时间让用户等待IMO。

#2


1  

You can use below link for fast insertion of data. We used it for saving 50000 records which done in few sec which was done in minutes

您可以使用以下链接快速插入数据。我们使用它来保存50000条记录,这些记录在几秒钟内完成,这些记录在几分钟内完成

Fast Insertion in database

快速插入数据库

#3


1  

14 best tips are available here Best Steps to increase performance of iOS App

这里提供了14个最佳技巧提高iOS App性能的最佳步骤

In this tutorial, point 13 gives the info you required.

在本教程中,第13点提供了您需要的信息。