Skip to content

Instantly share code, notes, and snippets.

@akio0911
Created May 26, 2009 08:30
Show Gist options
  • Save akio0911/117956 to your computer and use it in GitHub Desktop.
Save akio0911/117956 to your computer and use it in GitHub Desktop.
// 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