{"action":"created","issue":{"url":"https://api.github.com/repos/carekit-apple/CareKit/issues/27","repository_url":"https://api.github.com/repos/carekit-apple/CareKit","labels_url":"https://api.github.com/repos/carekit-apple/CareKit/issues/27/labels{/name}","comments_url":"https://api.github.com/repos/carekit-apple/CareKit/issues/27/comments","events_url":"https://api.github.com/repos/carekit-apple/CareKit/issues/27/events","html_url":"https://github.com/carekit-apple/CareKit/issues/27","id":153108429,"number":27,"title":"Rendering OCKInsightsChartTableViewCell causes lags","user":{"login":"mikehouse","id":2994667,"avatar_url":"https://avatars.githubusercontent.com/u/2994667?v=3","gravatar_id":"","url":"https://api.github.com/users/mikehouse","html_url":"https://github.com/mikehouse","followers_url":"https://api.github.com/users/mikehouse/followers","following_url":"https://api.github.com/users/mikehouse/following{/other_user}","gists_url":"https://api.github.com/users/mikehouse/gists{/gist_id}","starred_url":"https://api.github.com/users/mikehouse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mikehouse/subscriptions","organizations_url":"https://api.github.com/users/mikehouse/orgs","repos_url":"https://api.github.com/users/mikehouse/repos","events_url":"https://api.github.com/users/mikehouse/events{/privacy}","received_events_url":"https://api.github.com/users/mikehouse/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"YuanZhu-apple","id":11466704,"avatar_url":"https://avatars.githubusercontent.com/u/11466704?v=3","gravatar_id":"","url":"https://api.github.com/users/YuanZhu-apple","html_url":"https://github.com/YuanZhu-apple","followers_url":"https://api.github.com/users/YuanZhu-apple/followers","following_url":"https://api.github.com/users/YuanZhu-apple/following{/other_user}","gists_url":"https://api.github.com/users/YuanZhu-apple/gists{/gist_id}","starred_url":"https://api.github.com/users/YuanZhu-apple/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/YuanZhu-apple/subscriptions","organizations_url":"https://api.github.com/users/YuanZhu-apple/orgs","repos_url":"https://api.github.com/users/YuanZhu-apple/repos","events_url":"https://api.github.com/users/YuanZhu-apple/events{/privacy}","received_events_url":"https://api.github.com/users/YuanZhu-apple/received_events","type":"User","site_admin":false},"milestone":null,"comments":2,"created_at":"2016-05-04T20:34:19Z","updated_at":"2016-05-12T22:14:49Z","closed_at":null,"body":"Hi. Rendering a table view cell of the OCKInsightsChartTableViewCell class takes too many time. I can clearly see lags when I'm scrolling the table view with the cells of that class. \r\nI have some time measures:\r\n\r\n\r\nOCKTest[362:69627] Cell for row for class OCKInsightsMessageTableViewCell with time: 0.008754\r\nOCKTest[362:69627] Cell for row for class OCKInsightsChartTableViewCell with time: **0.108796**\r\nOCKTest[362:69627] Cell for row for class OCKInsightsMessageTableViewCell with time: 0.003148\r\nOCKTest[362:69627] Cell for row for class OCKInsightsChartTableViewCell with time: **0.080318**\r\nOCKTest[362:69627] Cell for row for class OCKInsightsMessageTableViewCell with time: 0.001522\r\nOCKTest[362:69627] Cell for row for class OCKInsightsChartTableViewCell with time: **0.124296**\r\nOCKTest[362:69627] Cell for row for class OCKInsightsChartTableViewCell with time: **0.129740**\r\nOCKTest[362:69627] Cell for row for class OCKInsightsMessageTableViewCell with time: 0.000314\r\nOCKTest[362:69627] Cell for row for class OCKInsightsMessageTableViewCell with time: 0.000287\r\n\r\nThe same we can see at Time Profiler tool (screenshot below).\r\n\r\n\r\n<img width=\"663\" alt=\"screen shot 2016-05-05 at 1 59 58 am\" src=\"https://cloud.githubusercontent.com/assets/2994667/15027781/42103670-1267-11e6-8da6-d667b700d4a6.png\">\r\n"},"comment":{"url":"https://api.github.com/repos/carekit-apple/CareKit/issues/comments/218901516","html_url":"https://github.com/carekit-apple/CareKit/issues/27#issuecomment-218901516","issue_url":"https://api.github.com/repos/carekit-apple/CareKit/issues/27","id":218901516,"user":{"login":"YuanZhu-apple","id":11466704,"avatar_url":"https://avatars.githubusercontent.com/u/11466704?v=3","gravatar_id":"","url":"https://api.github.com/users/YuanZhu-apple","html_url":"https://github.com/YuanZhu-apple","followers_url":"https://api.github.com/users/YuanZhu-apple/followers","following_url":"https://api.github.com/users/YuanZhu-apple/following{/other_user}","gists_url":"https://api.github.com/users/YuanZhu-apple/gists{/gist_id}","starred_url":"https://api.github.com/users/YuanZhu-apple/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/YuanZhu-apple/subscriptions","organizations_url":"https://api.github.com/users/YuanZhu-apple/orgs","repos_url":"https://api.github.com/users/YuanZhu-apple/repos","events_url":"https://api.github.com/users/YuanZhu-apple/events{/privacy}","received_events_url":"https://api.github.com/users/YuanZhu-apple/received_events","type":"User","site_admin":false},"created_at":"2016-05-12T22:14:49Z","updated_at":"2016-05-12T22:14:49Z","body":">Separate each of the components of the OKGroupedBarChartView into different UITableViewCells. So ?one cell for the title label, one cell for each of the bars, and one cell for the legend. This would allow each of these components to be reused as you scroll. It would also simplify the constraints for the cells, which is part of the reason it's taking a while to prepare. The major downside to this approach is it's a bit more complex, and you don't have a reusable OKGroupedBarChartView.\r\n\r\nThis would be really complex.\r\n\r\n> Add more caching for the OKGroupedBarChartView and reuse the views more, as opposed to recreating them every time. My hesitancy to this approach is that I'm not sure if it's possible to achieve optimal performance since these bar charts are pretty CPU-bound.\r\n\r\nThis could be the way to go.  Quick workaround would be create a custom OCKBarChart subclass which support chartview caching.\r\n\r\nAlso can you share with us how many bars on each of chart? \r\n\r\n\r\n"}}