ããã®åã®æ¥ææ¥ã«Kansai.pmã«åå ãã¦ãã¾ããã
Perlã®äººã§ããªããåå ãã¦ãè¯ãã®ããªãã¨æ©ã¿ã¾ããããHTML::ExtractContentãä½ã£ã人ã®è©±ãèããã®ã§è¡ã£ã¦ã¿ã¾ãããæ£ç´ãHatenaãè¦ããã®ã¨çid:naoyaãããè¦ããã£ãã¨ããã®ãããã¾ãw
ãä¸çªæåã®è©±ããåç°ããã«ããããã°ã©ã ã®é«éåã®è©±ããããªãã¬ãã«ã®é«ã話ã§ãå¨ãã®äººãé è¯ããããªäººã°ããã ã£ãã®ã§ãåå ããæééããããªãã¨ä¸äººå
å¿ç¦ã£ã¦ãã¾ããã
Cell Challenge 2009 参加記
ãé«éåã®è¦³ç¹ã¯ã以ä¸ã®ï¼ç¹
- ã¢ã«ã´ãªãºã ã®é«éå
- ããã並åå
- CPUï¼æ£ç¢ºã«ã¯ãSPEï¼ä¸ã¤åä½ã§ã®é«éå
- ãã¤ãã©ã¤ã³
- ãã¼ã¿ä¾åã¨ãã¼ã¿ãã¶ã¼ã
ã«ã¼ãã¢ã³ããã¼ãªã³ã°ã«ã¼ãã¢ã³ãã¼ãªã³ã°ãï¼è¨æ£ã2009/03/28 14:30ï¼
- è¤æ°CPUã§åæ£å¦çããããæã®é«éå
ãã©ããé£ããå
容ãã解ãæã説æãã¦é ããã®ã§å¤§å¤åå¼·ã«ãªãã¾ãããã©ã®è©±ãçºã«ãªã話ã ã£ãã®ã§ãããç¹ã«è¡æãåããã®ãCPUä¸ã¤åä½ã§ã®é«éåã®è©±ã§ããæåã«ï¼å½ä»¤ãè¤æ°å·¥ç¨ã«åå²ããããããªããå®è¡ãããã¤ãã©ã¤ã³å¦çã®èª¬æãããã¾ããã次ã«ãå·¥ç¨ã®ä¾åé¢ä¿ã«ããã¹ã«ã¼ããããè½ã¡ãä¾ï¼ãã¼ã¿ãã¶ã¼ãï¼ãå³è§£ãã¦é ãã¾ãããããã¾ã§ã ã£ãããæ
å ±å¦ç試é¨ãåãããã¨ããã人éãªãã°ã誰ã§ãç¥ã£ã¦ããå
容ã§ãããããããã®å¾ã«å
·ä½çã«ã©ãããã³ã¼ãã£ã³ã°ã§ããã°ããã¼ã¿ãã¶ã¼ããåé¿åºæ¥ãã®ãã¨ããä¾ã示ãã¦ããã¾ãããããã§ç§ã¯è¡æãåãã¾ãããCPUã®å¦çãèãã¦ã³ã¼ãã£ã³ã°ãããã¨ããªããªã¨ãç¥èã¨ãã¦æã£ã¦ããã³ã³ãã¥ã¼ã¿ã®åãã¨ããã®ãç¥èã®ã¾ã¾ã§çµãããã¦ããã¨ãããã¨ã«æ°ãä»ãããã¾ããã
ãå®éã®ã¨ãããã¢ããªãä½ãå ´åã¯ãã¡ã¤ã«ã¢ã¯ã»ã¹ãDBã¢ã¯ã»ã¹ã®è¾ºãã«ç¹ã«æ³¨æãæã£ã¦ããã°ãããã©ã¼ãã³ã¹ã®åé¡ãçºçãããã¨ã¯ã»ã¨ãã©ç¡ãã§ããããã§ããæ®æ®µããã¢ã¼ããã¯ãã£ã¼ãèãã¦ã³ã¼ãã£ã³ã°ãããã¨ã¯å¤§äºã ãªã¨æãã¾ãããï¼å¾è¼©ã«ã¯ãããDBã®æ°æã¡ã«ãªã£ã¦SQLãæ¸ãã¨è¨ã£ãããã¦ããã§ãããwæ¥ããããéãã§ããï¼
ãã¡ãªã¿ã«ãä¸è¨ã®ã³ã¼ãã¯ãã¼ã¿ãã¶ã¼ãã解æ¶ããçºã®ã³ã¼ãã£ã³ã°ä¾ã§ãããã¼ã¿ãã¶ã¼ãã¯ãå½ä»¤ãå©ç¨ãããã¼ã¿éã«ä¾åé¢ä¿ãããå ´åã«çºçãã¾ããåã®å½ä»¤ãçµãããªãã¨å¾ãã®å½ä»¤ãå®è¡ã§ããªãã¨ããã§ãã®ã§ãããã解ãã»ããã¦ããã°ã並åã§å¦çãåºæ¥ãããã«ãªãã¾ãã
追è¨ã2009/03/28 14:30
ä¸è¨ã®ä¾ã¯Loopã®è©ä¾¡ãç¡ãçºã«é«éã«ãªã£ã¦ããã ãã§ãã«ã¼ãã¢ã³ãã¼ãªã³ã°ã¨ã¯é¢ä¿ã®ãªã話ã§ãããç³ã訳ãããã¾ããã
è²ã
ãªæ¹ã«ã³ã¡ã³ãããã©ãã¯ããã¯ãã¯ã¦ãã§ææãã¦é ãã¾ããããããã¨ããããã¾ãã
#!/usr/bin/perl use strict; use warnings; use Time::HiRes qw ( time ); my $sum; my $start; my $end; my $max = 10000000; $sum = 0; $start = time(); for (my $i=0; $i<$max; $i++) { for (my $j=0; $j<3; $j++) { $sum = $sum+($i+$j); } } $end = time(); print $sum,"\n"; printf("%.4f secs\n", $end - $start); $sum = 0; $start = time(); for (my $i=0; $i<$max; $i++) { $sum = $sum+($i+0); $sum = $sum+($i+1); $sum = $sum+($i+2); } $end = time(); print $sum,"\n"; printf("%.4f secs\n", $end - $start);
$ ./test.pl 150000015000000 9.0000 secs 150000015000000 6.0000 secs
ã1.5åã«ãªãã¾ãããç®ã§è¦ã¦ã¿ãã¨é¢ç½ãã§ãã é«éåã¯ãforæã®è©ä¾¡ãå¿
è¦ãªãçºã§ããã«ã¼ãã¢ã³ãã¼ãªã³ã°ã¨ã¯ç¡é¢ä¿ã§ããã
ã¾ãé度ãã¨ãããä¿å®æ§ãã¨ããã¨è¨ãã°ãã»ã¨ãã©ã®å ´åã¯ä¿å®æ§ã§ããããããããã¡ããã¨æ¼ããã¦ããããã§ããã
Kansai.pmãã¿ã¯æ´çãã¦ã¾ã ã¾ã æ¸ãããã®ã§ãä¸å®æã§ç¶ãã¾ãã