真剣.js / shinken-js

2e7087b86608d4497c209eb9ba14d8f5?s=47 Sho Kusano
February 08, 2017

真剣.js / shinken-js

2e7087b86608d4497c209eb9ba14d8f5?s=128

Sho Kusano

February 08, 2017
Tweet

Transcript

  1. ੜెͷظ຤ࢼݧͭͬͯͯ͘Ϡό͍

  2. 쎙 쎅 썰 썫 썦 썡썴썦썽 썙 쎡 썟 쎁

    썛 쎒 쎀 ஗ 썛 ͋ͷ೔ͷύονΛͳͨ͘͠੨೥ͷ૕ࣦͱ࠶ੜͷ෺ޠ
  3. 4MBDLͷνʔϜ਺͕രൃ͖ͯͨ͠ !SPTZMJMMZ ݱࡏ͘Β͍ ೖͬͯͳ͍ͱ͜Ζ΋͋Δ

  4. ଎ ౓ 4 Q F F E δοαΠμΠδ

  5. (PךSFHFYQָ鹼ְ

  6. None
  7. None
  8. None
  9. $ go run regexp.go 2.07745267s $ ruby regexp.rb 1.709597 $

    node regexp.js 0.129
  10. (P͕଎͍ͬͯݴͬͨͷ୭ͩΑ

  11. > In some areas Go kann keep up with Java

    but when it comes to string > operations ("regex-dna" benchmark), Go is even much slower than Ruby > or Python. Is the status quo going to improve anytime soon? And why is > Go so terribly slow when it comes to string/RegEx operations? You assume the benchmark is worth something. First of all, Ruby and Python are using C implementations of the regexp search, so Go is being beat by C, not by Ruby. Second, Go is using a different algorithm for regexp matching than the C implementations in those other languages. The algorithm Go uses guarantees to complete in time that is linear in the length of the input. The algorithm that Ruby/Python/etc are using can take time exponential in the length of the input, although on trivial cases it typically runs quite fast. In order to guarantee the linear time bound, Go's algorithm's best case speed a little slower than the optimistic Ruby/Python/etc algorithm. On the other hand, there are inputs for which Go will return quickly and Ruby/Python/etc need more time than is left before the heat death of the universe. It's a decent tradeoff. http://swtch.com/~rsc/regexp/regexp1.html Russ at Golang-nuts IUUQTHSPVQTHPPHMFDPNGPSVNNTHHPMBOHOVUTENBFGK2ZH/:R3UT.+
  12. ೖྗจࣈྻͷ௕͞ʹԠͯ͡ઢܗʹॲཧ͕࣌ؒ৳ͼΔ ˠϢʔβʔͷೖྗͱ͔͕Ϡόͯ͘΋ॲཧ͕࣌ؒอূ͞ΕΔ ˠ࠷దͳέʔε ϓϩάϥϚͷೖྗ ͳͲʹରͯ͠͸ ɹ3VCZ΍1ZUIPOʹൺ΂ͯ஗͍

  13. SFHFYQ͸ආ͚Α͏ ৽نʹQBDLBHFΛ࢖͏ͱ͖͸DMPOFͯ͠HJUHSFQSFHFYQ҆ఆ

  14.  (PדTMJDFך⹛涸然⥂ָ鹼ְ

  15. None
  16. None
  17. ByAppend-4 20000 81987 ns/op 385784 B/op 20 allocs/op ByIndex-4 100000

    16803 ns/op 81920 B/op 1 allocs/op
  18. ಈతʹTMJDFʹཁૉΛ௥Ճ͢Δͱ Ұఆͷ௕͞Λ௒͑Δͱ࠶֬อ͢Δ

  19. ཁૉ਺͕Θ͔͍ͬͯΔ৔߹ͳΒ ͦͷαΠζͷΩϟύγςΟΛ ࣄલʹ֬อ͓ͯ͘͠΂͖

  20. (Pד8SJUFS׾ֲתֻ⢪ֲ

  21. )551ϨεϙϯεͰ+40/ΛૹΔࡍʹॻ͖͕ͪͳίʔυ

  22. func Endpoint( rw http.ResponseWriter, req *http.Request, ) { bytes, err

    := json.Marshal(model) rw.Write(bytes) } Ұ౓CZUFTMJDFΛੜ੒ͯ͠͠·͍ͬͯΔ
  23. func Endpoint( rw http.ResponseWriter, req *http.Request, ) { encoder :=

    json.NewEncoder(rw) encoder.Encode(model) } CZUFTMJDF͕࡞ΒΕͳ͍
  24. Bytes-4 200 7007896 ns/op 3915804 B/op 19 allocs/op Writer-4 200

    6565790 ns/op 1074462 B/op 5 allocs/op
  25. 8SJUFSΛแΉ8SJUFSͳͲ΋࡞ΕΔ #BTFH[JQ  ͷͰɺ׆༻͢ΔͱΑΓศརͰΘ͔Γ΍͘͢࢖͍͜ͳͤΔ

  26. BMMPDճ਺͕ݮΕ͹୯७ʹߴ଎Խʹ΋د༩͢ΔͷͰ ੵۃతʹ׆༻͠·͠ΐ͏ ͲͪΒ͔ͱ͍͑͹ϝϞϦෛՙܰݮ

  27. ࡉ͔͍ ੵΈॏͶ ࡉ͔͍ ੵΈॏͶ ࡉ͔͍ ੵΈॏͶ ࡉ͔͍ ੵΈॏͶ

  28. ଎͘ͳΔ ˣ μΠϨΫτͳتͼ

  29. ΍͍͖ͬͯ·͠ΐ͏

  30. ෇࿥

  31. ͜ ͷ Ұ ೥ Ͱ ͷ  ۜߦͷಈ͖

  32.  ๺෦৴૊ۜߦഇۀ

  33.  େ֞৴ۚͱ੢ೱ৴͕ۚ ߹ซ͠େ֞੢ೱ৴ۚʹ

  34.  ෢෦৴ۚɺ๛ӫ೶ڠഇۀ ࠇ෦೶ڠͱࠇ෦ࢢ৴༻೶ڠ ͕߹ซ͠ɺࠇ෦ࢢ೶ڠʹ

  35. ͳΜ͔௕͘ͳ͖ͬͯͨΜͰলུ͢Δͱ

  36. ৴ۚͷഇۀͱ૑ۀ ͙͢Θ͔Δ೥ͷۜߦτϨϯυ ೶ڠͷ߹ซϥογϡ ΞδΞݍࠃ֎ۜߦͷਐग़

  37. ৴ۚͷഇۀͱ૑ۀ ݹ͔͘Β͋Δ৴ۚͷղࢄͱ ৽ڵͷ৴૊ ࿑૊ ۜߦ͕ ೖΕସΘΔΑ͏ʹಈ͍͍ͯΔ ྫࢁܗݝҩࢣ৴૊ɺࡾॏݝ৬һ৴૊

  38. ೶ڠͷ߹ซϥογϡ ͍Θ͖ࢢ೶ۀڠಉ૊߹ɺ ܊ࢁࢢ೶ۀڠಉ૊߹ɺͨΉΒ೶ۀڠಉ૊߹ɺ ͍Θ͖த෦೶ۀڠಉ૊߹ɺ;ͨ͹೶ۀڠಉ૊߹ ෱ౡ͘͞Β೶ۀڠಉ૊߹ ˣ ஍۠୯Ґͩͬͨ೶ڠ͕ɺݝ୯ҐʹҠߦͭͭ͋͠Δ

  39. ೥ʹਐग़͖ͯͨ͠ࠃ֎ۜߦ ϑΟϦϐϯɾφγϣφϧɾόϯΫ ୆৽ᅳࡍ঎ۀ φγϣφϧΦʔετϥϦΞ ΞδΞݍࠃ֎ۜߦͷਐग़

  40. ۜߦ৘ใΛ௥͏ͱ ࢿۚݯྲྀಈͬΆ͍΋ͷ͕ݟ͑ͯ ͘͢͝ݏͳؾ࣋ͪʹͳָ͍ͬͯ͠

  41. ࠷ۜ ߴߦ