Created
May 26, 2009 08:30
-
-
Save akio0911/117956 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// test2 = 0.365886 // (float)M_PI | |
// test1 = 0.603662 // M_PI | |
#import "PiTestAppDelegate.h" | |
#define COUNT (1000000) | |
@implementation PiTestAppDelegate | |
@synthesize window; | |
void test1(float* array1, float* array2){ | |
for(int i = 0; i < COUNT; i++){ | |
array2[i] = array1[i] / M_PI * 180.0f; | |
} | |
} | |
void test2(float* array1, float* array2){ | |
for(int i = 0; i < COUNT; i++){ | |
array2[i] = array1[i] / (float)M_PI * 180.0f; | |
} | |
} | |
- (void)applicationDidFinishLaunching:(UIApplication *)application { | |
// Override point for customization after application launch | |
[window makeKeyAndVisible]; | |
float* arrayf1 = malloc(sizeof(float)*COUNT); | |
float* arrayf2 = malloc(sizeof(float)*COUNT); | |
for(int i = 0; i < COUNT; i++){ | |
arrayf1[i] = random(); | |
} | |
NSDate* a_dateStart1 = [NSDate date]; | |
test1(arrayf1, arrayf2); | |
NSLog(@"%s test1 = %f", __func__, [[NSDate date] timeIntervalSinceDate:a_dateStart1]); | |
NSDate* a_dateStart2 = [NSDate date]; | |
test2(arrayf1, arrayf2); | |
NSLog(@"%s test2 = %f", __func__, [[NSDate date] timeIntervalSinceDate:a_dateStart2]); | |
free(arrayf1); | |
free(arrayf2); | |
} | |
- (void)dealloc { | |
[window release]; | |
[super dealloc]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment