Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

PHP conference 2013 ja report

PHPカンファレンス2013のセッション、「PHPコアから読み解く、定石の嘘ホント」を参考にまとめたスライドです。

  • Be the first to comment

PHP conference 2013 ja report

  1. 1. 「PHPコアから読み解く 定石の嘘ホント」より @akirakoyasu PHP CONFERENCE 2013 9/14 Sat. 大田区産業プラザPiO
  2. 2. Copyright © 2013 Akira Koyasu. Some rights reserved. Theory 2 定石、定跡(じょうせき)とは、アブストラクトゲームに おける用語である。お互いが最善と考えられる手を行った 場合の一連の手のこと。チェスでは、「セオリー」とも。 石を用いる囲碁、オセロ、連珠などでは「定石」が、駒を 用いる将棋、チェスなどでは「定跡」が用いられる。 - ja.wikipedia.org photo#1
  3. 3. Copyright © 2013 Akira Koyasu. Some rights reserved. 3 Rule 2つのコードを見せます どちらが速く動くか考えてください 考える時間は10秒 相談しないで!
  4. 4. Copyright © 2013 Akira Koyasu. Some rights reserved. Execution Time 4 $time1 = microtime(true); // test code loop (100000 times) $time2 = microtime(true); printf("time: %f sn", ($time2 - $time1));
  5. 5. Copyright © 2013 Akira Koyasu. Some rights reserved. opcode 5 $ sudo pecl install channel://pecl.php.net/vld-0.12.0 $ php -dvld.active=1 -dvld.execute=0 test.php Extension vld
  6. 6. Copyright © 2013 Akira Koyasu. Some rights reserved. PHP runtime 6 .php.php.php Parser Compiler Virtual Machine
  7. 7. Copyright © 2013 Akira Koyasu. Some rights reserved. PHP runtime 6 .php.php.php Parser Compiler Virtual Machine AST 構文解析
  8. 8. Copyright © 2013 Akira Koyasu. Some rights reserved. PHP runtime 6 .php.php.php Parser Compiler Virtual Machineopcode AST 構文解析 コンパイル
  9. 9. Copyright © 2013 Akira Koyasu. Some rights reserved. PHP runtime 6 .php.php.php Parser Compiler Virtual Machineopcode AST 構文解析 コンパイル 実行
  10. 10. Copyright © 2013 Akira Koyasu. Some rights reserved. 7 Ready?
  11. 11. Copyright © 2013 Akira Koyasu. Some rights reserved. Loop 8 A B
  12. 12. Copyright © 2013 Akira Koyasu. Some rights reserved. Loop 8 $c = sizeof($arr); for ($i = 0; $i < $c; $i++) { $t = $arr[$i]; } foreach ($arr as $val) { $t = $val; } A B ただし、 とする$arr = range(0, 100);
  13. 13. Copyright © 2013 Akira Koyasu. Some rights reserved. Loop 8 $c = sizeof($arr); for ($i = 0; $i < $c; $i++) { $t = $arr[$i]; } foreach ($arr as $val) { $t = $val; } A B ただし、 とする$arr = range(0, 100);
  14. 14. Copyright © 2013 Akira Koyasu. Some rights reserved. foreach ($arr as $val) { $t = $val; } $c = sizeof($arr); for ($i = 0; $i < $c; $i++) { $t = $arr[$i]; } FE_RESET FE_FETCH DO_FCALL 'sizeof' IS_SMALLER POST_INC FETCH_DIM_R Answer 9 A B
  15. 15. Copyright © 2013 Akira Koyasu. Some rights reserved. foreach ($arr as $val) { $t = $val; } $c = sizeof($arr); for ($i = 0; $i < $c; $i++) { $t = $arr[$i]; } time: 0.683817 s FE_RESET FE_FETCH time: 1.043019 s DO_FCALL 'sizeof' IS_SMALLER POST_INC FETCH_DIM_R Answer 9 A B
  16. 16. Copyright © 2013 Akira Koyasu. Some rights reserved. foreach ($arr as $val) { $t = $val; } $c = sizeof($arr); for ($i = 0; $i < $c; $i++) { $t = $arr[$i]; } time: 0.683817 s FE_RESET FE_FETCH time: 1.043019 s DO_FCALL 'sizeof' IS_SMALLER POST_INC FETCH_DIM_R Answer 9 A B
  17. 17. Copyright © 2013 Akira Koyasu. Some rights reserved. foreach ($arr as $val) { $t = $val; } $c = sizeof($arr); for ($i = 0; $i < $c; $i++) { $t = $arr[$i]; } time: 0.683817 s FE_RESET FE_FETCHtime: 1.043019 s DO_FCALL 'sizeof' IS_SMALLER POST_INC FETCH_DIM_R Answer 9 A B
  18. 18. Copyright © 2013 Akira Koyasu. Some rights reserved. Elements 10 A B
  19. 19. Copyright © 2013 Akira Koyasu. Some rights reserved. Elements 10 if (count($arr) > 0) { ; } if (!empty($arr)) { ; } $arr = array();ただし、 とする A B
  20. 20. Copyright © 2013 Akira Koyasu. Some rights reserved. Elements 10 if (count($arr) > 0) { ; } if (!empty($arr)) { ; } $arr = array();ただし、 とする A B
  21. 21. Copyright © 2013 Akira Koyasu. Some rights reserved. Answer 11 if (count($arr) > 0) { ; } if (!empty($arr)) { ; } A B DO_FCALL 'count' IS_SMALLER ISSET_ISEMPTY_VAR BOOL_NOT
  22. 22. Copyright © 2013 Akira Koyasu. Some rights reserved. Answer 11 if (count($arr) > 0) { ; } if (!empty($arr)) { ; } A B time: 0.026228 s time: 0.008356 s DO_FCALL 'count' IS_SMALLER ISSET_ISEMPTY_VAR BOOL_NOT
  23. 23. Copyright © 2013 Akira Koyasu. Some rights reserved. Answer 11 if (count($arr) > 0) { ; } if (!empty($arr)) { ; } A B time: 0.026228 s time: 0.008356 s DO_FCALL 'count' IS_SMALLER ISSET_ISEMPTY_VAR BOOL_NOT
  24. 24. Copyright © 2013 Akira Koyasu. Some rights reserved. Answer 11 if (count($arr) > 0) { ; } if (!empty($arr)) { ; } A B time: 0.026228 s time: 0.008356 s DO_FCALL 'count' IS_SMALLER ISSET_ISEMPTY_VAR BOOL_NOT
  25. 25. Copyright © 2013 Akira Koyasu. Some rights reserved. 12 Points 測ってみる 調べてみる 考えてみる
  26. 26. Copyright © 2013 Akira Koyasu. Some rights reserved. 13 Any Questions?
  27. 27. Copyright © 2013 Akira Koyasu. Some rights reserved. Notes This work is licensed under the Creative Commons Attribution- NonCommercial 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc/3.0/. 14 photo#1: http://www.flickr.com/photos/sbl/1617711/ Thank you very much, Feedback Welcome! http://twitter.com/akirakoyasu http://fb.me/akirakoyasu http://www.akirakoyasu.net

    Be the first to comment

    Login to see the comments

  • TakamasaUchino

    Jul. 23, 2017

PHPカンファレンス2013のセッション、「PHPコアから読み解く、定石の嘘ホント」を参考にまとめたスライドです。

Views

Total views

730

On Slideshare

0

From embeds

0

Number of embeds

3

Actions

Downloads

4

Shares

0

Comments

0

Likes

1

×