Created
August 20, 2012 15:30
-
-
Save sonsongithub/3405180 to your computer and use it in GitHub Desktop.
Defulat pre-comiple header
This file contains 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
#if TARGET_IPHONE_SIMULATOR | |
#import <objc/objc-runtime.h> | |
#else | |
#import <objc/runtime.h> | |
#endif | |
#include <stdlib.h> | |
#include <stdio.h> | |
#include <sys/time.h> | |
#pragma mark - for Debug | |
#ifdef _DEBUG | |
#define DNSLog(...) NSLog(__VA_ARGS__); | |
#define DNSLogMethod NSLog(@"[%s] %@", class_getName([self class]), NSStringFromSelector(_cmd)); | |
#define DNSLogPoint(p) NSLog(@"%f,%f", p.x, p.y); | |
#define DNSLogSize(p) NSLog(@"%f,%f", p.width, p.height); | |
#define DNSLogRect(p) NSLog(@"%f,%f %f,%f", p.origin.x, p.origin.y, p.size.width, p.size.height); | |
#else | |
#define DNSLog(...) // | |
#define DNSLogMethod // | |
#define DNSLogPoint(p) // | |
#define DNSLogSize(p) // | |
#define DNSLogRect(p) // | |
#endif | |
#pragma mark - for Profiling | |
static struct timeval _start, _end; | |
static void _tic() { | |
gettimeofday(&_start, NULL); | |
} | |
static void _toc() { | |
gettimeofday(&_end, NULL); | |
long int e_sec = _end.tv_sec * 1000000 + _end.tv_usec; | |
long int s_sec = _start.tv_sec * 1000000 + _start.tv_usec; | |
printf( "%9.4lf[ms]\n", (double)(e_sec - s_sec) / 1000.0); | |
} | |
static double _tocWithoutLog() { | |
gettimeofday(&_end, NULL); | |
long int e_sec = _end.tv_sec * 1000000 + _end.tv_usec; | |
long int s_sec = _start.tv_sec * 1000000 + _start.tv_usec; | |
return (double)(e_sec - s_sec) / 1000.0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment