开发者

iOS ASIHTTPRequest response time problem

I am just calling Synchronous call like followings a few times, checking response time..

NSURL *url = [NSURL URLWithString:@"http://myurl.com"];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];

NSDate *start=[NSDate date];
NSLog(@"Start date %@", start);

[request startSynchronous];

NSDate *end=[NSDate date];
NSLog(@"End date %@", end);

double ellapsedSeconds= [end timeIntervalSinceDate:start];
NSLog(@"response time %f", ellapsedSeconds);

Funny thing is response time is too much different between first time and others.. Is there some cache related?

2011-09-18 23:20:55.608 ON THE GO[2073:707] Star开发者_JAVA百科t date 2011-09-18 13:20:55 +0000

2011-09-18 23:20:59.204 ON THE GO[2073:707] ASI Response test=test

2011-09-18 23:20:59.208 ON THE GO[2073:707] End date 2011-09-18 13:20:59 +0000

2011-09-18 23:20:59.209 ON THE GO[2073:707] response time 3.600945

2011-09-18 23:20:59.211 ON THE GO[2073:707] Start date 2011-09-18 13:20:59 +0000

2011-09-18 23:20:59.212 ON THE GO[2073:707] ASI Response test=test

2011-09-18 23:20:59.216 ON THE GO[2073:707] End date 2011-09-18 13:20:59 +0000

2011-09-18 23:20:59.217 ON THE GO[2073:707] response time 0.003545

2011-09-18 23:20:59.223 ON THE GO[2073:707] Start date 2011-09-18 13:20:59 +0000

2011-09-18 23:20:59.225 ON THE GO[2073:707] ASI Response test=test

2011-09-18 23:20:59.227 ON THE GO[2073:707] End date 2011-09-18 13:20:59 +0000

2011-09-18 23:20:59.228 ON THE GO[2073:707] response time 0.004832

2011-09-18 23:20:59.232 ON THE GO[2073:707] Start date 2011-09-18 13:20:59 +0000

2011-09-18 23:20:59.235 ON THE GO[2073:707] ASI Response test=test

2011-09-18 23:20:59.238 ON THE GO[2073:707] End date 2011-09-18 13:20:59 +0000

2011-09-18 23:20:59.239 ON THE GO[2073:707] response time 0.005358

2011-09-18 23:20:59.241 ON THE GO[2073:707] Start date 2011-09-18 13:20:59 +0000

2011-09-18 23:20:59.242 ON THE GO[2073:707] ASI Response test=test

2011-09-18 23:20:59.250 ON THE GO[2073:707] End date 2011-09-18 13:20:59 +0000

2011-09-18 23:20:59.251 ON THE GO[2073:707] response time 0.007573


Probably, to confirm this add the following line after creating the request (shown)

ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request setCachePolicy:ASIDoNotWriteToCacheCachePolicy|ASIDoNotReadFromCacheCachePolicy];

This will tell ASI not to read or write from the cache.

If you then rerun the test, it should show the same time for all the requests.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜