Created
May 26, 2009 07:32
-
-
Save akio0911/117940 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
// test3 = 0.922481 atan2f float | |
// test4 = 1.067147 atan2f double | |
// test2 = 2.844713 atan2 double | |
// test1 = 3.252539 atan2 float | |
#import "Atan2TestAppDelegate.h" | |
#define COUNT (1000000) | |
@implementation Atan2TestAppDelegate | |
@synthesize window; | |
void test1(float* array1, float* array2, float* array3){ | |
for(int i = 0; i < COUNT; i++){ | |
array3[i] = atan2(array1[i], array2[i]); | |
} | |
} | |
void test2(double* array1, double* array2, double* array3){ | |
for(int i = 0; i < COUNT; i++){ | |
array3[i] = atan2(array1[i], array2[i]); | |
} | |
} | |
void test3(float* array1, float* array2, float* array3){ | |
for(int i = 0; i < COUNT; i++){ | |
array3[i] = atan2f(array1[i], array2[i]); | |
} | |
} | |
void test4(double* array1, double* array2, double* array3){ | |
for(int i = 0; i < COUNT; i++){ | |
array3[i] = atan2f(array1[i], array2[i]); | |
} | |
} | |
- (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); | |
float* arrayf3 = malloc(sizeof(float)*COUNT); | |
double* arrayd1 = malloc(sizeof(double)*COUNT); | |
double* arrayd2 = malloc(sizeof(double)*COUNT); | |
double* arrayd3 = malloc(sizeof(double)*COUNT); | |
for(int i = 0; i < COUNT; i++){ | |
arrayf1[i] = random(); | |
arrayf2[i] = random(); | |
arrayd1[i] = random(); | |
arrayd2[i] = random(); | |
} | |
NSDate* a_dateStart1 = [NSDate date]; | |
test1(arrayf1, arrayf2, arrayf3); | |
NSLog(@"%s test1 = %f", __func__, [[NSDate date] timeIntervalSinceDate:a_dateStart1]); | |
NSDate* a_dateStart2 = [NSDate date]; | |
test2(arrayd1, arrayd2, arrayd3); | |
NSLog(@"%s test2 = %f", __func__, [[NSDate date] timeIntervalSinceDate:a_dateStart2]); | |
NSDate* a_dateStart3 = [NSDate date]; | |
test3(arrayf1, arrayf2, arrayf3); | |
NSLog(@"%s test3 = %f", __func__, [[NSDate date] timeIntervalSinceDate:a_dateStart3]); | |
NSDate* a_dateStart4 = [NSDate date]; | |
test4(arrayd1, arrayd2, arrayd3); | |
NSLog(@"%s test4 = %f", __func__, [[NSDate date] timeIntervalSinceDate:a_dateStart4]); | |
free(arrayf1); | |
free(arrayf2); | |
free(arrayf3); | |
free(arrayd1); | |
free(arrayd2); | |
free(arrayd3); | |
} | |
- (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