Code profiling time inside blocks

How to use tools for profiling code in the block? Now I can see the total time for the Bloc, but I can not enter into the block to see where time is consumed.

As examples, in case 1:

if (completionBlock) { completionBlock(mutableManagedObjects, mutableBackingObjects); } 

and case 2:

 [backingContext performBlockAndWait:^{ if (backingObjectID) { backingObject = [backingContext existingObjectWithID:backingObjectID error:nil]; } else { backingObject = [NSEntityDescription insertNewObjectForEntityForName:entity.name inManagedObjectContext:backingContext]; } }]; : backingContext]; [backingContext performBlockAndWait:^{ if (backingObjectID) { backingObject = [backingContext existingObjectWithID:backingObjectID error:nil]; } else { backingObject = [NSEntityDescription insertNewObjectForEntityForName:entity.name inManagedObjectContext:backingContext]; } }]; 

In case 1, I can not be profiled within the function and see the time spent; it just shows the total time for the block. In case 2, as I only get the% of the total block; it does not show the details for the code strings inside.

+6
source share
2 answers

Create separate blocks and check the profile of each of them.

 /*! \brief check first for backingContext as it is not set yet up here if (backingObjectID) { [backingContext performBlockAndWait:^{ backingObject = [backingContext existingObjectWithID:backingObjectID error:nil]; }]; } else { [backingContext performBlockAndWait:^{ backingObject = [NSEntityDescription insertNewObjectForEntityForName:entity.name inManagedObjectContext:backingContext]; }]; }]; is not set yet up here /*! \brief check first for backingContext as it is not set yet up here if (backingObjectID) { [backingContext performBlockAndWait:^{ backingObject = [backingContext existingObjectWithID:backingObjectID error:nil]; }]; } else { [backingContext performBlockAndWait:^{ backingObject = [NSEntityDescription insertNewObjectForEntityForName:entity.name inManagedObjectContext:backingContext]; }]; }]; : nil]; /*! \brief check first for backingContext as it is not set yet up here if (backingObjectID) { [backingContext performBlockAndWait:^{ backingObject = [backingContext existingObjectWithID:backingObjectID error:nil]; }]; } else { [backingContext performBlockAndWait:^{ backingObject = [NSEntityDescription insertNewObjectForEntityForName:entity.name inManagedObjectContext:backingContext]; }]; }]; : backingContext]; /*! \brief check first for backingContext as it is not set yet up here if (backingObjectID) { [backingContext performBlockAndWait:^{ backingObject = [backingContext existingObjectWithID:backingObjectID error:nil]; }]; } else { [backingContext performBlockAndWait:^{ backingObject = [NSEntityDescription insertNewObjectForEntityForName:entity.name inManagedObjectContext:backingContext]; }]; }]; 
0
source

Now you can go into the block, starting with Xcode 6.0.1.

0
source

All Articles