-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix performance #44
Fix performance #44
Conversation
last_response = @client.last_response | ||
$t_after = Time.now.instance_eval { self.to_i * 1000 + (usec/1000) } | ||
puts "ccc: #{$t_after - $t_before}"; | ||
$t_before = $t_after | ||
|
||
while last_response.rels[:next] && in_range?(user_events.last) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
やはり GitHub へのアクセス回数がパフォーマンスダウンの影響。
ここの loop に入ると 30 行目の last_response = last_response.rels[:next].get
でアクセスしてしまう。
そうならないように、17 行目の user_events = @client.user_events(@user, per_page: 100)
のように Pagination を調整すれば良さそう。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
10〜100 に変更してパフォーマンスを図ったところ、雑に増やしても影響はないことが分かった。Ruby の処理が増えるだけなので。
10: 13.860 sec
20: 12.427 sec
30: 12.546 sec (default)
40: 10.451 sec #<= 今回はここから1ページに収まった
50: 11.125 sec
60: 11.699 sec
70: 11.467 sec
80: 11.329 sec
90: 11.125 sec
100: 11.463 sec
200: 11.317 sec
雑に 100 にしよう。
@@ -106,7 +106,7 @@ def hash_for_issue(repo_name, issue_number) | |||
title: issue.title.markdown_escape, | |||
repo_basename: repo_name, | |||
username: issue.user.login, | |||
merged: client.pull_merged?(repo_name, issue.number), | |||
merged: issue.merged, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#44 (comment) に書いた、GitHub へのアクセス回数を減らす施策。
このときの issue
はすぐ上にある client.issue(repo_name, issue_number)
で取得した変数。現在の Issue を指し示しているため、Octokit::Client#pull_merged?
で GitHub にアクセスする必要はない。
Before
After