// main.m - By Michael G. Workman // // An example Objective C application to generate and output a list // // This example application freely distributable under terms of MIT open source license #import #import #define NUMBER_ELEMENTS 100000 int main(int argc, const char* argv[]) { // time interval typedef double NSTimeInterval; // generate list NSMutableArray* list = [[NSMutableArray alloc] init]; // start timing NSDate *startTime = [NSDate date]; // add 1 hundred thousand consecutive integers to the list for (int i = 0; i < NUMBER_ELEMENTS; i++) { [list addObject:[NSNumber numberWithInt:i]]; } // output the contents of the list for (int i = 0; i < NUMBER_ELEMENTS; i++) { NSLog(@"%@", list[i]); } // end timing NSDate *endTime = [NSDate date]; // get elapsed time NSTimeInterval elapsedTime = [endTime timeIntervalSinceDate:startTime]; // get number of elements int numberElements = [list count]; // output the results NSLog(@"Objective C time to build and display list: %f seconds", elapsedTime); NSLog(@"Number Elements: %i", numberElements); return 0; }