Search code examples
iosobjective-cnsurlrequest

Antenna usage when sending a batch of http requests


I'm trying to optimize battery usage when networking. If I hold all my http requests in an array for example, then I send them all (just empty out the array at once (for loop)), will the antenna turn on once to perform the 10 requests, or will it turn on and off n times? (I'm using NSURLRequest)

Is there a way to batch send requests at once? Or is this basically "batch" sending requests.


Solution

  • The documentation says nothing about how iDevice's hardware handles multiple NSURLRequests. It can be that handling on one model or OS version is different than on another one (e.g. iPhone 4 vs iPhone 5).

    You will have to use Instruments and research it on your own using Energy Diagnostics. However, this is rather simple. Here is a short plan how to do it:

    1. Connect the device to your development system.
    2. Launch Xcode or Instruments.
    3. On the device, choose Settings > Developer and turn on power logging.
    4. Disconnect the device and perform the desired tests.
    5. Reconnect the device.
    6. In Instruments, open the Energy Diagnostics template.
    7. Choose File > Import Energy Diagnostics from Device.

    Moreover, have a look at Analyzing CPU Usage in Your App