clock_t begin = clock(); [self foo]; clock_t end = clock(); double cost = (double)(end - begin) / CLOCKS_PER_SEC;