{"action":"created","issue":{"url":"https://api.github.com/repos/cmseaton42/task-easy/issues/2","repository_url":"https://api.github.com/repos/cmseaton42/task-easy","labels_url":"https://api.github.com/repos/cmseaton42/task-easy/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/cmseaton42/task-easy/issues/2/comments","events_url":"https://api.github.com/repos/cmseaton42/task-easy/issues/2/events","html_url":"https://github.com/cmseaton42/task-easy/issues/2","id":310229053,"number":2,"title":"Is reordering before executing each task efficient? ","user":{"login":"andrewsokolov","id":336626,"avatar_url":"https://avatars3.githubusercontent.com/u/336626?v=4","gravatar_id":"","url":"https://api.github.com/users/andrewsokolov","html_url":"https://github.com/andrewsokolov","followers_url":"https://api.github.com/users/andrewsokolov/followers","following_url":"https://api.github.com/users/andrewsokolov/following{/other_user}","gists_url":"https://api.github.com/users/andrewsokolov/gists{/gist_id}","starred_url":"https://api.github.com/users/andrewsokolov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrewsokolov/subscriptions","organizations_url":"https://api.github.com/users/andrewsokolov/orgs","repos_url":"https://api.github.com/users/andrewsokolov/repos","events_url":"https://api.github.com/users/andrewsokolov/events{/privacy}","received_events_url":"https://api.github.com/users/andrewsokolov/received_events","type":"User","site_admin":false},"labels":[{"id":877370655,"url":"https://api.github.com/repos/cmseaton42/task-easy/labels/enhancement","name":"enhancement","color":"a2eeef","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-03-31T10:01:51Z","updated_at":"2018-04-01T03:54:45Z","closed_at":null,"author_association":"NONE","body":"Maybe heap will be more situated for that case then plain array?"},"comment":{"url":"https://api.github.com/repos/cmseaton42/task-easy/issues/comments/377741855","html_url":"https://github.com/cmseaton42/task-easy/issues/2#issuecomment-377741855","issue_url":"https://api.github.com/repos/cmseaton42/task-easy/issues/2","id":377741855,"user":{"login":"cmseaton42","id":18745936,"avatar_url":"https://avatars2.githubusercontent.com/u/18745936?v=4","gravatar_id":"","url":"https://api.github.com/users/cmseaton42","html_url":"https://github.com/cmseaton42","followers_url":"https://api.github.com/users/cmseaton42/followers","following_url":"https://api.github.com/users/cmseaton42/following{/other_user}","gists_url":"https://api.github.com/users/cmseaton42/gists{/gist_id}","starred_url":"https://api.github.com/users/cmseaton42/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cmseaton42/subscriptions","organizations_url":"https://api.github.com/users/cmseaton42/orgs","repos_url":"https://api.github.com/users/cmseaton42/repos","events_url":"https://api.github.com/users/cmseaton42/events{/privacy}","received_events_url":"https://api.github.com/users/cmseaton42/received_events","type":"User","site_admin":false},"created_at":"2018-04-01T03:54:45Z","updated_at":"2018-04-01T03:54:45Z","author_association":"OWNER","body":"The initial thought process behind calling `_reorder` before running each tasks are as follows.\r\n\r\n- we do not know how long each scheduled task will take to complete thus many additional tasks could be added during the execution of the active task thus requiring us to `_reorder` again to ensure any high priority tasks that may have been added during the current execution bubble up as appropriate.\r\n- `_reorder` runs in O(n) time. For common use cases, the overhead associated running `_reorder` is negligible.\r\n- this was done in the interest of keeping it simple in the short term\r\n\r\n\r\nTo answer your question though, no it not the most efficient way to do this. I think the following optimizations could be easily made to decrease overhead.\r\n- add an `_insert` method that pushes a new item onto the array and then allows the item to swim up to an appropriate position within the array to satisfy the `max-heap` condition. This could be done in O(lgn) time.\r\n- add a `_remove` method that takes the highest priority item off the top and re-establishes the `max-heap` property. This could also be done in O(lgn) time.\r\n\r\nDid you have any other ways in mind to improve performance? \r\n\r\nAlso, thanks for pointing this out."}}
{"actor":{"display_login":"cmseaton42"}}