統計をとって高速化するscala開発 by cyberz,inc
DESCRIPTION
http://scalamatsuri.org/TRANSCRIPT
![Page 1: 統計をとって高速化するScala開発 by CyberZ,Inc](https://reader033.vdocuments.pub/reader033/viewer/2022060110/555d78a7d8b42a0b778b5809/html5/thumbnails/1.jpg)
統計をとって高速化するScala開発
引用:jigokuno.com
![Page 2: 統計をとって高速化するScala開発 by CyberZ,Inc](https://reader033.vdocuments.pub/reader033/viewer/2022060110/555d78a7d8b42a0b778b5809/html5/thumbnails/2.jpg)
自己紹介
名前 小笠原みつき @yamitzky
会社 株式会社CyberZ
Scala歴 2ヶ月Ruby歴 4年
スマホ広告のアドテク企業です!
![Page 3: 統計をとって高速化するScala開発 by CyberZ,Inc](https://reader033.vdocuments.pub/reader033/viewer/2022060110/555d78a7d8b42a0b778b5809/html5/thumbnails/3.jpg)
去年のScala Conference、覚えていますか?
![Page 4: 統計をとって高速化するScala開発 by CyberZ,Inc](https://reader033.vdocuments.pub/reader033/viewer/2022060110/555d78a7d8b42a0b778b5809/html5/thumbnails/4.jpg)
James Roperさんのライブコーディング
掲示板をその場で開発
引用:vimeo.com/65556263
![Page 5: 統計をとって高速化するScala開発 by CyberZ,Inc](https://reader033.vdocuments.pub/reader033/viewer/2022060110/555d78a7d8b42a0b778b5809/html5/thumbnails/5.jpg)
James Roperさんのライブコーディング
スニペットを入力して……
smff
![Page 6: 統計をとって高速化するScala開発 by CyberZ,Inc](https://reader033.vdocuments.pub/reader033/viewer/2022060110/555d78a7d8b42a0b778b5809/html5/thumbnails/6.jpg)
James Roperさんのライブコーディング
ッターン! 引用:jigokuno.com
![Page 7: 統計をとって高速化するScala開発 by CyberZ,Inc](https://reader033.vdocuments.pub/reader033/viewer/2022060110/555d78a7d8b42a0b778b5809/html5/thumbnails/7.jpg)
こんなふうに開発できたら気持ちいい……!
![Page 8: 統計をとって高速化するScala開発 by CyberZ,Inc](https://reader033.vdocuments.pub/reader033/viewer/2022060110/555d78a7d8b42a0b778b5809/html5/thumbnails/8.jpg)
IntelliJのLive Template
![Page 9: 統計をとって高速化するScala開発 by CyberZ,Inc](https://reader033.vdocuments.pub/reader033/viewer/2022060110/555d78a7d8b42a0b778b5809/html5/thumbnails/9.jpg)
IntelliJのLive Template
スニペットを入力して……
![Page 10: 統計をとって高速化するScala開発 by CyberZ,Inc](https://reader033.vdocuments.pub/reader033/viewer/2022060110/555d78a7d8b42a0b778b5809/html5/thumbnails/10.jpg)
IntelliJのLive Template
ッターン!
![Page 11: 統計をとって高速化するScala開発 by CyberZ,Inc](https://reader033.vdocuments.pub/reader033/viewer/2022060110/555d78a7d8b42a0b778b5809/html5/thumbnails/11.jpg)
IntelliJのLive Template
変数も補完!
![Page 12: 統計をとって高速化するScala開発 by CyberZ,Inc](https://reader033.vdocuments.pub/reader033/viewer/2022060110/555d78a7d8b42a0b778b5809/html5/thumbnails/12.jpg)
何のスニペット作ろう……?
![Page 13: 統計をとって高速化するScala開発 by CyberZ,Inc](https://reader033.vdocuments.pub/reader033/viewer/2022060110/555d78a7d8b42a0b778b5809/html5/thumbnails/13.jpg)
そうだ、データをとろう!
![Page 14: 統計をとって高速化するScala開発 by CyberZ,Inc](https://reader033.vdocuments.pub/reader033/viewer/2022060110/555d78a7d8b42a0b778b5809/html5/thumbnails/14.jpg)
ソースコードのワードカウント
ワードカウント
単語 出現数 出現率( 2 6%) 2 6%
String 1 3%def 1 3%… … …
![Page 15: 統計をとって高速化するScala開発 by CyberZ,Inc](https://reader033.vdocuments.pub/reader033/viewer/2022060110/555d78a7d8b42a0b778b5809/html5/thumbnails/15.jpg)
社内で集計してみました
![Page 16: 統計をとって高速化するScala開発 by CyberZ,Inc](https://reader033.vdocuments.pub/reader033/viewer/2022060110/555d78a7d8b42a0b778b5809/html5/thumbnails/16.jpg)
CyberZでの集計
順位 単語 出現率 順位 単語 出現率
1 . 9.96% 13 -> 1.22%2 ( 8.67% 14 Long 1.04%
3 ) 8.67% 15 => 1.04%
4 , 6.85% 16 val 1.03%
5 : 3.82% 17 rs 0.92%
6 = 2.58% 18 id 0.81%
7 " 2.08% 19 c 0.80%
8 [ 1.90% 20 rn 0.76%
9 ] 1.90% 21 String 0.63%
10 { 1.88% 22 * 0.51%
11 } 1.88% 23 Option 0.50%
12 def 1.24% 24 get 0.46%
![Page 17: 統計をとって高速化するScala開発 by CyberZ,Inc](https://reader033.vdocuments.pub/reader033/viewer/2022060110/555d78a7d8b42a0b778b5809/html5/thumbnails/17.jpg)
グラフにしてみた
出現順位
出現率
0%
2.5%
5%
7.5%
10%
200 400 600 800
![Page 18: 統計をとって高速化するScala開発 by CyberZ,Inc](https://reader033.vdocuments.pub/reader033/viewer/2022060110/555d78a7d8b42a0b778b5809/html5/thumbnails/18.jpg)
グラフにしてみた
出現順位
出現率
0%
2.5%
5%
7.5%
10%
200 400 600 800
一部の単語だけが頻出する
![Page 19: 統計をとって高速化するScala開発 by CyberZ,Inc](https://reader033.vdocuments.pub/reader033/viewer/2022060110/555d78a7d8b42a0b778b5809/html5/thumbnails/19.jpg)
グラフにしてみた
出現順位
出現率
0%
2.5%
5%
7.5%
10%
200 400 600 800
上位24件で61%
![Page 20: 統計をとって高速化するScala開発 by CyberZ,Inc](https://reader033.vdocuments.pub/reader033/viewer/2022060110/555d78a7d8b42a0b778b5809/html5/thumbnails/20.jpg)
両対数グラフにしてみると……
![Page 21: 統計をとって高速化するScala開発 by CyberZ,Inc](https://reader033.vdocuments.pub/reader033/viewer/2022060110/555d78a7d8b42a0b778b5809/html5/thumbnails/21.jpg)
0
0.01
1 10 100
両対数グラフ
直線!
(あまり出てこない単語)
(頻出単語)
出現順位
出現率
![Page 22: 統計をとって高速化するScala開発 by CyberZ,Inc](https://reader033.vdocuments.pub/reader033/viewer/2022060110/555d78a7d8b42a0b778b5809/html5/thumbnails/22.jpg)
ジップの法則
英語でも成り立つ法則出現順位
出現率
TheAnd
QualityReality
引用:pha.jhu.edu/~rittner/fractal.html
(あまり出てこない単語)
(頻出単語)
![Page 23: 統計をとって高速化するScala開発 by CyberZ,Inc](https://reader033.vdocuments.pub/reader033/viewer/2022060110/555d78a7d8b42a0b778b5809/html5/thumbnails/23.jpg)
話を戻して…
出現順位
出現率
0%
2.5%
5%
7.5%
10%
200 400 600 800
上位24件で61%
![Page 24: 統計をとって高速化するScala開発 by CyberZ,Inc](https://reader033.vdocuments.pub/reader033/viewer/2022060110/555d78a7d8b42a0b778b5809/html5/thumbnails/24.jpg)
まずは61%を省略する戦略で Live Templateを作ってみる
![Page 25: 統計をとって高速化するScala開発 by CyberZ,Inc](https://reader033.vdocuments.pub/reader033/viewer/2022060110/555d78a7d8b42a0b778b5809/html5/thumbnails/25.jpg)
CyberZでの集計
順位 単語 出現率 順位 単語 出現率
1 . 9.96% 13 -> 1.22%2 ( 8.67% 14 Long 1.04%
3 ) 8.67% 15 => 1.04%
4 , 6.85% 16 val 1.03%
5 : 3.82% 17 rs 0.92%
6 = 2.58% 18 id 0.81%
7 " 2.08% 19 c 0.80%
8 [ 1.90% 20 rn 0.76%
9 ] 1.90% 21 String 0.63%
10 { 1.88% 22 * 0.51%
11 } 1.88% 23 Option 0.50%
12 def 1.24% 24 get 0.46%
def, valをスニペット化
![Page 26: 統計をとって高速化するScala開発 by CyberZ,Inc](https://reader033.vdocuments.pub/reader033/viewer/2022060110/555d78a7d8b42a0b778b5809/html5/thumbnails/26.jpg)
一文字に割り当てる
同時にカッコや = も補完
“d”
“v”
![Page 27: 統計をとって高速化するScala開発 by CyberZ,Inc](https://reader033.vdocuments.pub/reader033/viewer/2022060110/555d78a7d8b42a0b778b5809/html5/thumbnails/27.jpg)
例
![Page 28: 統計をとって高速化するScala開発 by CyberZ,Inc](https://reader033.vdocuments.pub/reader033/viewer/2022060110/555d78a7d8b42a0b778b5809/html5/thumbnails/28.jpg)
例
vだけ入れて…
![Page 29: 統計をとって高速化するScala開発 by CyberZ,Inc](https://reader033.vdocuments.pub/reader033/viewer/2022060110/555d78a7d8b42a0b778b5809/html5/thumbnails/29.jpg)
例
ッターン!
![Page 30: 統計をとって高速化するScala開発 by CyberZ,Inc](https://reader033.vdocuments.pub/reader033/viewer/2022060110/555d78a7d8b42a0b778b5809/html5/thumbnails/30.jpg)
例
![Page 31: 統計をとって高速化するScala開発 by CyberZ,Inc](https://reader033.vdocuments.pub/reader033/viewer/2022060110/555d78a7d8b42a0b778b5809/html5/thumbnails/31.jpg)
例
![Page 32: 統計をとって高速化するScala開発 by CyberZ,Inc](https://reader033.vdocuments.pub/reader033/viewer/2022060110/555d78a7d8b42a0b778b5809/html5/thumbnails/32.jpg)
結果
val <変数名> = <値>
v<タブ>
7文字
2文字
- 71%
![Page 33: 統計をとって高速化するScala開発 by CyberZ,Inc](https://reader033.vdocuments.pub/reader033/viewer/2022060110/555d78a7d8b42a0b778b5809/html5/thumbnails/33.jpg)
CyberZでの集計
順位 単語 出現率 順位 単語 出現率
1 . 9.96% 13 -> 1.22%2 ( 8.67% 14 Long 1.04%
3 ) 8.67% 15 => 1.04%
4 , 6.85% 16 val 1.03%
5 : 3.82% 17 rs 0.92%
6 = 2.58% 18 id 0.81%
7 " 2.08% 19 c 0.80%
8 [ 1.90% 20 rn 0.76%
9 ] 1.90% 21 String 0.63%
10 { 1.88% 22 * 0.51%
11 } 1.88% 23 Option 0.50%
12 def 1.24% 24 get 0.46%いくつかの型はよく入力される
![Page 34: 統計をとって高速化するScala開発 by CyberZ,Inc](https://reader033.vdocuments.pub/reader033/viewer/2022060110/555d78a7d8b42a0b778b5809/html5/thumbnails/34.jpg)
よく使う型のLive Templateを登録
“S”
“L”
“O”
“I”
![Page 35: 統計をとって高速化するScala開発 by CyberZ,Inc](https://reader033.vdocuments.pub/reader033/viewer/2022060110/555d78a7d8b42a0b778b5809/html5/thumbnails/35.jpg)
よく使う型のLive Templateを登録
“S”
“L”
“O”
“I”
- 67%
- 33%
- 50%
- 75%
![Page 36: 統計をとって高速化するScala開発 by CyberZ,Inc](https://reader033.vdocuments.pub/reader033/viewer/2022060110/555d78a7d8b42a0b778b5809/html5/thumbnails/36.jpg)
ここまでで
![Page 37: 統計をとって高速化するScala開発 by CyberZ,Inc](https://reader033.vdocuments.pub/reader033/viewer/2022060110/555d78a7d8b42a0b778b5809/html5/thumbnails/37.jpg)
なんと……!
![Page 38: 統計をとって高速化するScala開発 by CyberZ,Inc](https://reader033.vdocuments.pub/reader033/viewer/2022060110/555d78a7d8b42a0b778b5809/html5/thumbnails/38.jpg)
約8%を省略理論上は100時間開発したら8時間短縮できる
![Page 39: 統計をとって高速化するScala開発 by CyberZ,Inc](https://reader033.vdocuments.pub/reader033/viewer/2022060110/555d78a7d8b42a0b778b5809/html5/thumbnails/39.jpg)
Groovy Scriptを使うとこんなことも
![Page 40: 統計をとって高速化するScala開発 by CyberZ,Inc](https://reader033.vdocuments.pub/reader033/viewer/2022060110/555d78a7d8b42a0b778b5809/html5/thumbnails/40.jpg)
メソッドのログ出力
![Page 41: 統計をとって高速化するScala開発 by CyberZ,Inc](https://reader033.vdocuments.pub/reader033/viewer/2022060110/555d78a7d8b42a0b778b5809/html5/thumbnails/41.jpg)
メソッドのログ出力
![Page 42: 統計をとって高速化するScala開発 by CyberZ,Inc](https://reader033.vdocuments.pub/reader033/viewer/2022060110/555d78a7d8b42a0b778b5809/html5/thumbnails/42.jpg)
メソッドのログ出力
ッターン!
![Page 43: 統計をとって高速化するScala開発 by CyberZ,Inc](https://reader033.vdocuments.pub/reader033/viewer/2022060110/555d78a7d8b42a0b778b5809/html5/thumbnails/43.jpg)
SQLの生成
![Page 44: 統計をとって高速化するScala開発 by CyberZ,Inc](https://reader033.vdocuments.pub/reader033/viewer/2022060110/555d78a7d8b42a0b778b5809/html5/thumbnails/44.jpg)
SQLの生成
![Page 45: 統計をとって高速化するScala開発 by CyberZ,Inc](https://reader033.vdocuments.pub/reader033/viewer/2022060110/555d78a7d8b42a0b778b5809/html5/thumbnails/45.jpg)
SQLの生成
ッターン!
![Page 46: 統計をとって高速化するScala開発 by CyberZ,Inc](https://reader033.vdocuments.pub/reader033/viewer/2022060110/555d78a7d8b42a0b778b5809/html5/thumbnails/46.jpg)
まとめ
IntelliJのLive Templateを使いこなそう!
ソースもあるよ!https://github.com/yamitzky/scala-intellij