大きなお友達の間で有名な日記サイト変人窟ですが、ページ読み込み速度のベンチマークとして使われている事は周知の事実です。
先日画像サーバをダウンさせた事件は記憶に新しいですが、元祖(?)Windows版が青くなった開発者によって削除されたり、Android版がリリースされたり、画像ストレージがPicasaになったり、何故かAndroid版がアップデートされたりと、未だ活発なようです。
んで。
えーまじー? アイフィョーン? きもーい 窟ベンチができるのはAndroidだけだよね?っていうのが流行らないかななんて #窟べんち
……!!!
Android Marketは自由度が高いので気軽にアプリを出せるようですが、iPhoneはそういうわけにも行きません。審査で蹴られる気がします。多分。
だからと言って「アイフィョーン」とか「きもーい」とか言われているのは癪なので、簡単に作ってみました。
以下、適当なコード。
#import <UIKit/UIKit.h>@interface ViewController : UIViewController
{NSTimer *timer;
}@property (retain, nonatomic) IBOutlet UIWebView *browser;
@property (retain, nonatomic) IBOutlet UIBarButtonItem *doBtn;
@property (retain, nonatomic) IBOutlet UIBarButtonItem *resetBtn;
@property (retain, nonatomic) IBOutlet UILabel *score;
@property (retain, nonatomic) IBOutlet UILabel *condition;
- (void)loadPage;
- (void)clearPage;
- (void)webViewDidStartLoad:(UIWebView *)webView;
- (void)webViewDidFinishLoad:(UIWebView *)webView;
- (IBAction)startDown:(id)sender;
- (IBAction)resetDown:(id)sender;
@property (assign) BOOL measuring;
@property (assign) BOOL timerAvailable;
@property (retain, nonatomic) NSDate *stDate;
- (void)startTimer;
- (void)stopTimer;
- (void)resetTimer;
- (void)onTimer:(NSTimer *)timer;
@end
#import "ViewController.h"@implementation ViewController@synthesize browser;@synthesize doBtn;@synthesize resetBtn;@synthesize score;@synthesize condition;@synthesize measuring;@synthesize timerAvailable;@synthesize stDate;- (void)didReceiveMemoryWarning
{[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.}#pragma mark - View lifecycle- (void)viewDidLoad
{[super viewDidLoad];
measuring = FALSE;self.score.text = @"tap start";
timerAvailable = FALSE;[self resetTimer];
timer = [NSTimer scheduledTimerWithTimeInterval:(0.01)
target:selfselector:@selector(onTimer:)
userInfo:nil
repeats:YES];
// Do any additional setup after loading the view, typically from a nib.}- (void)viewDidUnload
{[self setBrowser:nil];
[self setDoBtn:nil];
[self setResetBtn:nil];
[self setScore:nil];
[self setCondition:nil];
[super viewDidUnload];
// Release any retained subviews of the main view.// e.g. self.myOutlet = nil;}- (void)viewWillAppear:(BOOL)animated
{[super viewWillAppear:animated];
}- (void)viewDidAppear:(BOOL)animated
{[super viewDidAppear:animated];
}- (void)viewWillDisappear:(BOOL)animated
{[super viewWillDisappear:animated];
}- (void)viewDidDisappear:(BOOL)animated
{[super viewDidDisappear:animated];
}- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{// Return YES for supported orientationsreturn (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}- (void)dealloc {
[browser release];
[doBtn release];
[resetBtn release];
[score release];
[condition release];
[super dealloc];
}- (void)loadPage
{[browser loadRequest:[NSURLRequest requestWithURL:[NSURL
URLWithString:@"http://www.henjinkutsu.net"]]];
}- (void)clearPage
{NSString *htmlString = @"≶html style=\"background-color:#444\"></html>";
[browser loadHTMLString:htmlString baseURL:nil];
}- (void)webViewDidStartLoad:(UIWebView *)webView
{NSLog(@"start load...");
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
if (timerAvailable)
{[self startTimer];
}}- (void)webViewDidFinishLoad:(UIWebView *)webView
{[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
NSLog(@"finish load...");
if (timerAvailable)
{[self stopTimer];
}}- (IBAction)startDown:(id)sender
{NSLog(@"start...");
timerAvailable = TRUE;[self loadPage];
}- (IBAction)resetDown:(id)sender
{NSLog(@"reset...");
[self resetTimer];
}- (void)startTimer
{measuring = TRUE;condition.text = @"loading: ";
stDate = [NSDate date];
[stDate retain];
}- (void)stopTimer
{condition.text = @"done: ";
measuring = FALSE;}- (void)resetTimer
{self.timerAvailable = FALSE;[self clearPage];
condition.text = @"prepared: ";
score.text = @"0.00 sec";
}- (void)onTimer:(NSTimer *)timer
{if (measuring)
{NSDate *now = [NSDate date];
self.score.text = [NSString stringWithFormat:@"%.2f sec", [now
timeIntervalSinceDate:stDate]];
}}@end
ご利用は計画的にお願いします。
↓アイコンもどうぞ↓



