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.

GroovyでJSON2014

2,965 views

Published on

Published in: Software
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (Unlimited) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... Download Full EPUB Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... ACCESS WEBSITE for All Ebooks ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... Download EPUB Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... Download doc Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (Unlimited) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... Download Full EPUB Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... ACCESS WEBSITE for All Ebooks ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... Download EPUB Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... Download doc Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (Unlimited) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... Download Full EPUB Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... ACCESS WEBSITE for All Ebooks ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... Download EPUB Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... Download doc Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (Unlimited) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... Download Full EPUB Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... ACCESS WEBSITE for All Ebooks ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... Download EPUB Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... Download doc Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (Unlimited) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... Download Full EPUB Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... ACCESS WEBSITE for All Ebooks ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... Download EPUB Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... Download doc Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

GroovyでJSON2014

  1. 1. 速水 康晴
  2. 2. !  速水 康晴(はやみ やすはる) !  新潟県新潟市在住 !  ウイングアーク1st株式会社 新潟オフィス ◦  プログラマ:Java/Flex/ActionScript !  JGGUGサポート・スタッフ !  E-mail:toby55kij@gmail.com !  Twitter:toby55kij 2 2014/06/20
  3. 3. !  GroovyでJSONを扱う !  Groovy2.3での変更点 !  ライブラリ間の速度比較 2014/06/20 3
  4. 4. 2014/6/13 ↓ 13日の金曜日 ↓ JSON日の金曜日 (新潟市で行われているJSON勉強会飲み会) ↓ JSONの話 2014/06/20 4
  5. 5. !  バージョン1.8からサポート ◦  groovy.json.JsonBuilder !  JSON作成用Builder ◦  groovy.json.StreamingJsonBuilder !  Writerに書きこむJsonBuilder:1.8.1から ◦  groovy.json.JsonOutput !  JSONとしてオブジェクトを文字列に出力 ◦  groovy.json.JsonSlurper !  JSON文字列・ファイルの読み込み 2014/06/20 5
  6. 6. !  JsonBuilder:JSON文字列をDSLで構築 ◦  Writerに直接書き込む:StreamingJsonBuilder !  例: def json = new groovy.json.JsonBuilder() json { person { firstName 'Yasuharu' lastName 'Hayami' } age 42 } println json.toString() 2014/06/20 6
  7. 7. !  JsonOutput:オブジェクトを文字列に出力 ◦  prettyPrint(String)で文字列を整形 !  例:
 def obj = [person:
 [firstName: 'Yasuharu', lastName: 'Hayami'],
 age: 42]
 File file = new File('output.json')
 use(groovy.json.JsonOutput) {
 file.text = obj.toJson().prettyPrint()
 } 2014/06/20 7
  8. 8. !  JsonSlurper:JSON文字列を読み込む ◦  結果はJavaのListやMapに !  例: def slurper = new groovy.json.JsonSlurper() def data = slurper.parseText '''{ "person": { "firstName": "Yasuharu", "lastName": "Hayami" }, "age": 42 }''' println "${groovy.json.JsonOutput.toJson data}" 2014/06/20 8
  9. 9. !  JsonBuilderのリストでClosure指定が可能に 例:リスト内Songの値はtitleだけ出力したい class Song { String title … } def mySongs = [new Song (title: "Title 1", …), new Song (title: "Title 2", …), …] JsonBuilder json = new JsonBuilder() def map = json { //今まで songs mySongs.collect { Song s -> json { title s.title } } } 2014/06/20 9
  10. 10. !  JsonBuilderのリストでClosure指定が可能に 例:リスト内Songの値はtitleだけ出力したい class Song { String title … } def mySongs = [new Song (title: "Title 1", …), new Song (title: "Title 2", …), …] JsonBuilder json = new JsonBuilder() def map = json { //2.3から songs mySongs, { Song s -> title s.title } } 2014/06/20 10
  11. 11. !  JsonSlurper/JsonOutputのパフォーマンス改善 ◦  BoonのJSON実装を基に !  http://richardhightower.github.io/site/Boon/ ◦  JsonSlurperは以前より最大21倍高速(リリースノート) !  他のライブラリと比較して大雑把に2~4倍高速 ◦  JsonOutputは以前より最大17倍高速(リリースノート) !  他のライブラリと同程度の速度に →本当か?! 2014/06/20 11
  12. 12. !  JsonSlurperで解析の種類を選択:type ◦  値はJsonParserType !  CHARACTER_SOURCE:Readerで読みながら !  大きいファイル(2MB以上)で使用 !  CHAR_BUFFER:一旦文字列バッファ(char配列)に読み込む !  デフォルト、数字・日付を「きちんと」解析したい場合に使用 !  LAX:値を文字列バッファへのポインタで持つ !  コメントを含む場合に使用 !  長期的に値を持つ場合'Chop'か'Lazy Chop'を指定しておく !  INDEX_OVERLAY:値を文字列バッファへのポインタで持つ !  最速、2MB以下での使用がおすすめ !  長期的に値を持つ場合'Chop'か'Lazy Chop'を指定しておく 2014/06/20 12
  13. 13. !  https://github.com/bura/json-benchmarks ◦  Groovy, Jackson, Gson, Boonの比較 ◦  計測にはJMHを使用 !  ops/sを計測 !  データは4種類 ◦  citys:単純な内容で29,470個のArray ◦  repos:複雑な内容で4個のArray ◦  user:複雑な内容のObject ◦  request:単純な内容のObject 2014/06/20 13
  14. 14. !  動作環境:MacBook Air, Core i7 1.7GHz, 8GB ◦  今使っているMac ◦  作業しつつ計測:値は参考程度に !  なるべく最新のバージョンへ変更 ◦  Groovy:2.3.3と2.2.2 ◦  Jackson:2.4.0 ◦  Gson:2.2.4 ◦  Boon:0.20 ◦  JMH:0.9 →https://github.com/toby55kij/json-benchmarks 2014/06/20 14
  15. 15. !  Groovyと他のライブラリを比較 Groovy2.3.3を基準:値が大きいほど良い性能 ◦  Deserialization(JsonSlurper) !  Jackson:0.35~5.49 !  Gson:0.25~5.61 !  Boon:1.06~16.8 ◦  Serialization(JsonOutput) !  Jackson:0.90~1.33 !  Gson:0.40~0.81 !  Boon:1.55~100 →Jackson,Gsonより大抵の場合は高速 citysの性能が良くない 2014/06/20 15
  16. 16. !  Groovy2.2.2と2.3.3の比較 Groovy2.2.2を基準:値が大きいほど良い性能 ◦  Deserialization(JsonSlurper) !  Groovy2.3.3:1.41~39.97 ◦  Serialization(JsonOutput) !  Groovy2.3.3:12.6~27.9 →2.2より明らかに高速 2014/06/20 16
  17. 17. 次の13日の金曜日は? ↓ 2015/2/13 ご清聴ありがとうございました 2014/06/20 17

×