Upgrade to Pro — share decks privately, control downloads, hide ads and more …

RubyとPythonはどちらが速いのか

 RubyとPythonはどちらが速いのか

Lightening talk at #tqrk13

Avatar for Hiroki Yoshioka

Hiroki Yoshioka

June 29, 2019
Tweet

More Decks by Hiroki Yoshioka

Other Decks in Programming

Transcript

  1. Copyright Drecom Co., Ltd. All Rights Reserved. !2 自己紹介 吉岡ひろき

    Webエンジニア irohiroki / いろ 登壇、執筆 少々
  2. Copyright Drecom Co., Ltd. All Rights Reserved. !4 今どきのゲーム 何でも自動

    自動戦闘 自動移動 自動アイテム処分 自動装備 自動パーティ編成 …
  3. Copyright Drecom Co., Ltd. All Rights Reserved. !5 今どきのゲーム 何でも自動

    自動戦闘 自動移動 自動アイテム処分 自動装備 自動パーティ編成 … 組合せ最適化問題 ʢ͍ΘΏΔφοϓαοΫ໰୊ʣ
  4. Copyright Drecom Co., Ltd. All Rights Reserved. !6 組合せ最適化問題 近似解法

    ミツバチコロニー最適化など 厳密解法 動的計画法 バックトラッキング 分岐限界法 など
  5. Copyright Drecom Co., Ltd. All Rights Reserved. !11 分岐限界法 #

    Value Cost V/C 1 14 4 3.5 2 18 6 3 3 5 2 2.5 4 3 2 1.5 Cap=6
  6. Copyright Drecom Co., Ltd. All Rights Reserved. !12 分岐限界法 V:0,

    C:0 UB:20 # Value Cost V/C 1 14 4 3.5 2 18 6 3 3 5 2 2.5 4 3 2 1.5 Cap=6 UB = 14 + 18 * (6 - 4) / 6
  7. Copyright Drecom Co., Ltd. All Rights Reserved. !13 分岐限界法 V:0,

    C:0 UB:20 V:14, C:4 UB: 20 # Value Cost V/C 1 14 4 3.5 2 18 6 3 3 5 2 2.5 4 3 2 1.5 Cap=6 + I1 UB = 14 + 18 * (6 - 4) / 6
  8. Copyright Drecom Co., Ltd. All Rights Reserved. !14 分岐限界法 V:0,

    C:0 UB:20 V:14, C:4 UB: 20 V: , C:10 UB: # Value Cost V/C 1 14 4 3.5 2 18 6 3 3 5 2 2.5 4 3 2 1.5 Cap=6 + I1 + I2
  9. Copyright Drecom Co., Ltd. All Rights Reserved. !15 分岐限界法 V:0,

    C:0 UB:20 V:14, C:4 UB: 20 V: , C:10 UB: V:14, C:4 UB:19 # Value Cost V/C 1 14 4 3.5 2 18 6 3 3 5 2 2.5 4 3 2 1.5 Cap=6 + I1 + I2 - I2 UB = 14 + 5 * (6 - 4) / 2
  10. Copyright Drecom Co., Ltd. All Rights Reserved. !16 分岐限界法 V:0,

    C:0 UB:20 V:14, C:4 UB: 20 V:0, C:0 UB: 18 V: , C:10 UB: V:14, C:4 UB:19 # Value Cost V/C 1 14 4 3.5 2 18 6 3 3 5 2 2.5 4 3 2 1.5 Cap=6 + I1 - I1 + I2 - I2
  11. Copyright Drecom Co., Ltd. All Rights Reserved. !17 分岐限界法 V:0,

    C:0 UB:20 V:14, C:4 UB: 20 V:0, C:0 UB: 18 V: , C:10 UB: V:14, C:4 UB:19 # Value Cost V/C 1 14 4 3.5 2 18 6 3 3 5 2 2.5 4 3 2 1.5 Cap=6 V:19, C:6 UB:19 + I1 - I1 + I2 - I2 + I3
  12. Copyright Drecom Co., Ltd. All Rights Reserved. !18 分岐限界法 V:0,

    C:0 UB:20 V:14, C:4 UB: 20 V:0, C:0 UB: 18 V: , C:10 UB: V:14, C:4 UB:19 # Value Cost V/C 1 14 4 3.5 2 18 6 3 3 5 2 2.5 4 3 2 1.5 Cap=6 V:19, C:6 UB:19 V:14, C:4 UB:17 + I1 - I1 + I2 - I2 + I3 - I3
  13. Copyright Drecom Co., Ltd. All Rights Reserved. !19 分岐限界法 V:0,

    C:0 UB:20 V:14, C:4 UB: 20 V:0, C:0 UB: 18 V: , C:10 UB: V:14, C:4 UB:19 # Value Cost V/C 1 14 4 3.5 2 18 6 3 3 5 2 2.5 4 3 2 1.5 Cap=6 V:19, C:6 UB:19 V:14, C:4 UB:17 + I1 - I1 + I2 - I2 + I3 - I3
  14. Copyright Drecom Co., Ltd. All Rights Reserved. !22 テストデータ アイテム数

    … 200 Value … 1 〜 10 Cost … 1 〜 10 キャパシティ … 500
  15. Copyright Drecom Co., Ltd. All Rights Reserved. !24 118 /

    200 3.5 x 1057 通り Rubyで解く
  16. Copyright Drecom Co., Ltd. All Rights Reserved. アイテム数 … 200

    Value … 1 〜 10 Cost … 1 〜 10 キャパシティ … 503 !34 テストデータ2 +3
  17. Copyright Drecom Co., Ltd. All Rights Reserved. !44 Python vs

    Ruby https://www.educba.com/python-vs-ruby-performance/
  18. Copyright Drecom Co., Ltd. All Rights Reserved. !47 https://www.educba.com/python-vs-ruby-performance/ Python

    vs Ruby ؆͕ܿͩ σόοά͠ʹ͍͘͜ͱ΋ ໌ࣔత͕ͩ ΤϨΨϯτͰͳ͍͜ͱ΋
  19. Copyright Drecom Co., Ltd. All Rights Reserved. !50 おまけ -

    Python書いたら self忘れる return忘れる メソッド呼ぶとき()忘れる メソッドじゃないのに()つけちゃう true → True y if x else z