{"action":"created","comment":{"url":"https://api.github.com/repos/rock-core/base-scripts/pulls/comments/89325415","pull_request_review_id":9870953,"id":89325415,"diff_hunk":"@@ -30,57 +38,53 @@ if !(options[:task_name] || options[:port_name])\n     exit\n end\n \n-require 'orocos'\n Orocos.initialize\n \n task = Orocos.get options[:task_name]\n port = task.port options[:port_name]\n-buffersize = options[:buffersize] || 1000\n-port_reader = port.reader :type => :buffer, :size => buffersize\n+port_reader = port.reader type: :buffer, size: options[:buffersize],\n+    pull: options[:pull]\n \n-queue = []\n-max_queue_size = 10\n-one_s_counter = 0\n-one_s_timer = Time.now\n-progress_message = nil\n+min_reporting_period = 1\n+def compute_frequency(now, queue, window_duration)\n+    return 0 if queue.empty?\n+\n+    deadline = now - window_duration\n+    while !queue.empty? && (queue.last < deadline)\n+        queue.pop\n+    end\n+    if !queue.empty?\n+        Float(queue.size) / (now - queue.last)\n+    else\n+        0\n+    end\n+end\n \n begin\n-    while true\n-            sample_counter = 0\n-            while port_reader.read_new && (Time.now - one_s_timer) < 1\n-                sample_counter += 1\n-                if sample_counter > buffersize\n-                    msg = \"\\nPlease increase buffer size (using option '-b') since it is likely overflown.\\n\"\n-                    msg += \"     - current buffer size: #{buffersize}\\n\"\n-                    msg += \"     - samples read in less than a second: #{sample_counter}\"\n-                    puts msg\n-                    exit -1\n-                end\n-                one_s_counter += 1\n-            end\n-\n-            if queue.size != max_queue_size || ! (ten_s_frequency = queue.reduce(:+)/10)\n-                ten_s_frequency = \"n/a\"\n-            end\n-\n-            # Terminal code to go up 1 line and clear the line\n-            print \"\\r\" + (\"\\e[A\\e[K\"*2) if progress_message\n-\n-            progress_message = \"message frequency (past 1 second):     #{one_s_counter}\\n\"\n-            progress_message += \"message frequency (past 10 seconds):   #{ten_s_frequency}\"\n-            puts \"#{progress_message}\"\n-\n-\n-            if (Time.now - one_s_timer) > 1\n-                if queue.size == max_queue_size\n-                    queue.pop\n-                end\n-                queue.push one_s_counter\n-                one_s_counter = 0\n-                one_s_timer = Time.now\n-            end\n+    one_s_queue = []\n+    one_s_filled = false\n+    ten_s_queue = []\n+    ten_s_filled = false\n \n+    while true\n+        start_time  = Time.now\n+        has_new_samples = false\n+        while port_reader.read_new && (Time.now - start_time) < min_reporting_period\n+            has_new_samples = true\n+            one_s_queue.unshift Time.now\n+            ten_s_queue.unshift Time.now\n+        end\n+\n+        now = Time.now\n+        one_s = compute_frequency(now, one_s_queue, 1)\n+        ten_s = compute_frequency(now, ten_s_queue, 10)\n+\n+        # Terminal code to go up 1 line and clear the line","path":"bin/rock-hz","position":115,"original_position":115,"commit_id":"1313ac29c28165b5069da7a202a5000a3b6bd6d3","original_commit_id":"1313ac29c28165b5069da7a202a5000a3b6bd6d3","user":{"login":"2maz","id":5468166,"avatar_url":"https://avatars.githubusercontent.com/u/5468166?v=3","gravatar_id":"","url":"https://api.github.com/users/2maz","html_url":"https://github.com/2maz","followers_url":"https://api.github.com/users/2maz/followers","following_url":"https://api.github.com/users/2maz/following{/other_user}","gists_url":"https://api.github.com/users/2maz/gists{/gist_id}","starred_url":"https://api.github.com/users/2maz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/2maz/subscriptions","organizations_url":"https://api.github.com/users/2maz/orgs","repos_url":"https://api.github.com/users/2maz/repos","events_url":"https://api.github.com/users/2maz/events{/privacy}","received_events_url":"https://api.github.com/users/2maz/received_events","type":"User","site_admin":false},"body":"The comment is still there, but the corresponding code not. \r\nI would want to keep the in place update for the terminal as it was before","created_at":"2016-11-23T14:26:05Z","updated_at":"2016-11-23T14:26:05Z","html_url":"https://github.com/rock-core/base-scripts/pull/30#discussion_r89325415","pull_request_url":"https://api.github.com/repos/rock-core/base-scripts/pulls/30","_links":{"self":{"href":"https://api.github.com/repos/rock-core/base-scripts/pulls/comments/89325415"},"html":{"href":"https://github.com/rock-core/base-scripts/pull/30#discussion_r89325415"},"pull_request":{"href":"https://api.github.com/repos/rock-core/base-scripts/pulls/30"}}},"pull_request":{"url":"https://api.github.com/repos/rock-core/base-scripts/pulls/30","id":94882900,"html_url":"https://github.com/rock-core/base-scripts/pull/30","diff_url":"https://github.com/rock-core/base-scripts/pull/30.diff","patch_url":"https://github.com/rock-core/base-scripts/pull/30.patch","issue_url":"https://api.github.com/repos/rock-core/base-scripts/issues/30","number":30,"state":"open","locked":false,"title":"Improve rock hz","user":{"login":"doudou","id":292,"avatar_url":"https://avatars.githubusercontent.com/u/292?v=3","gravatar_id":"","url":"https://api.github.com/users/doudou","html_url":"https://github.com/doudou","followers_url":"https://api.github.com/users/doudou/followers","following_url":"https://api.github.com/users/doudou/following{/other_user}","gists_url":"https://api.github.com/users/doudou/gists{/gist_id}","starred_url":"https://api.github.com/users/doudou/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/doudou/subscriptions","organizations_url":"https://api.github.com/users/doudou/orgs","repos_url":"https://api.github.com/users/doudou/repos","events_url":"https://api.github.com/users/doudou/events{/privacy}","received_events_url":"https://api.github.com/users/doudou/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-11-22T19:35:57Z","updated_at":"2016-11-23T14:26:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ac725275ede738ac87f4b44e758447f3a5c1e416","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/rock-core/base-scripts/pulls/30/commits","review_comments_url":"https://api.github.com/repos/rock-core/base-scripts/pulls/30/comments","review_comment_url":"https://api.github.com/repos/rock-core/base-scripts/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rock-core/base-scripts/issues/30/comments","statuses_url":"https://api.github.com/repos/rock-core/base-scripts/statuses/1313ac29c28165b5069da7a202a5000a3b6bd6d3","head":{"label":"rock-core:improve_rock_hz","ref":"improve_rock_hz","sha":"1313ac29c28165b5069da7a202a5000a3b6bd6d3","user":{"login":"rock-core","id":6654878,"avatar_url":"https://avatars.githubusercontent.com/u/6654878?v=3","gravatar_id":"","url":"https://api.github.com/users/rock-core","html_url":"https://github.com/rock-core","followers_url":"https://api.github.com/users/rock-core/followers","following_url":"https://api.github.com/users/rock-core/following{/other_user}","gists_url":"https://api.github.com/users/rock-core/gists{/gist_id}","starred_url":"https://api.github.com/users/rock-core/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rock-core/subscriptions","organizations_url":"https://api.github.com/users/rock-core/orgs","repos_url":"https://api.github.com/users/rock-core/repos","events_url":"https://api.github.com/users/rock-core/events{/privacy}","received_events_url":"https://api.github.com/users/rock-core/received_events","type":"Organization","site_admin":false},"repo":{"id":19274613,"name":"base-scripts","full_name":"rock-core/base-scripts","owner":{"login":"rock-core","id":6654878,"avatar_url":"https://avatars.githubusercontent.com/u/6654878?v=3","gravatar_id":"","url":"https://api.github.com/users/rock-core","html_url":"https://github.com/rock-core","followers_url":"https://api.github.com/users/rock-core/followers","following_url":"https://api.github.com/users/rock-core/following{/other_user}","gists_url":"https://api.github.com/users/rock-core/gists{/gist_id}","starred_url":"https://api.github.com/users/rock-core/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rock-core/subscriptions","organizations_url":"https://api.github.com/users/rock-core/orgs","repos_url":"https://api.github.com/users/rock-core/repos","events_url":"https://api.github.com/users/rock-core/events{/privacy}","received_events_url":"https://api.github.com/users/rock-core/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rock-core/base-scripts","description":"Scripts to interact with a Rock installation","fork":false,"url":"https://api.github.com/repos/rock-core/base-scripts","forks_url":"https://api.github.com/repos/rock-core/base-scripts/forks","keys_url":"https://api.github.com/repos/rock-core/base-scripts/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rock-core/base-scripts/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rock-core/base-scripts/teams","hooks_url":"https://api.github.com/repos/rock-core/base-scripts/hooks","issue_events_url":"https://api.github.com/repos/rock-core/base-scripts/issues/events{/number}","events_url":"https://api.github.com/repos/rock-core/base-scripts/events","assignees_url":"https://api.github.com/repos/rock-core/base-scripts/assignees{/user}","branches_url":"https://api.github.com/repos/rock-core/base-scripts/branches{/branch}","tags_url":"https://api.github.com/repos/rock-core/base-scripts/tags","blobs_url":"https://api.github.com/repos/rock-core/base-scripts/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rock-core/base-scripts/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rock-core/base-scripts/git/refs{/sha}","trees_url":"https://api.github.com/repos/rock-core/base-scripts/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rock-core/base-scripts/statuses/{sha}","languages_url":"https://api.github.com/repos/rock-core/base-scripts/languages","stargazers_url":"https://api.github.com/repos/rock-core/base-scripts/stargazers","contributors_url":"https://api.github.com/repos/rock-core/base-scripts/contributors","subscribers_url":"https://api.github.com/repos/rock-core/base-scripts/subscribers","subscription_url":"https://api.github.com/repos/rock-core/base-scripts/subscription","commits_url":"https://api.github.com/repos/rock-core/base-scripts/commits{/sha}","git_commits_url":"https://api.github.com/repos/rock-core/base-scripts/git/commits{/sha}","comments_url":"https://api.github.com/repos/rock-core/base-scripts/comments{/number}","issue_comment_url":"https://api.github.com/repos/rock-core/base-scripts/issues/comments{/number}","contents_url":"https://api.github.com/repos/rock-core/base-scripts/contents/{+path}","compare_url":"https://api.github.com/repos/rock-core/base-scripts/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rock-core/base-scripts/merges","archive_url":"https://api.github.com/repos/rock-core/base-scripts/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rock-core/base-scripts/downloads","issues_url":"https://api.github.com/repos/rock-core/base-scripts/issues{/number}","pulls_url":"https://api.github.com/repos/rock-core/base-scripts/pulls{/number}","milestones_url":"https://api.github.com/repos/rock-core/base-scripts/milestones{/number}","notifications_url":"https://api.github.com/repos/rock-core/base-scripts/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rock-core/base-scripts/labels{/name}","releases_url":"https://api.github.com/repos/rock-core/base-scripts/releases{/id}","deployments_url":"https://api.github.com/repos/rock-core/base-scripts/deployments","created_at":"2014-04-29T11:50:14Z","updated_at":"2016-02-24T18:22:23Z","pushed_at":"2016-11-22T19:35:57Z","git_url":"git://github.com/rock-core/base-scripts.git","ssh_url":"git@github.com:rock-core/base-scripts.git","clone_url":"https://github.com/rock-core/base-scripts.git","svn_url":"https://github.com/rock-core/base-scripts","homepage":null,"size":299,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":5,"forks":5,"open_issues":5,"watchers":0,"default_branch":"master"}},"base":{"label":"rock-core:master","ref":"master","sha":"593d0da4ef9ef13fb9e3af0012df49659fa122cc","user":{"login":"rock-core","id":6654878,"avatar_url":"https://avatars.githubusercontent.com/u/6654878?v=3","gravatar_id":"","url":"https://api.github.com/users/rock-core","html_url":"https://github.com/rock-core","followers_url":"https://api.github.com/users/rock-core/followers","following_url":"https://api.github.com/users/rock-core/following{/other_user}","gists_url":"https://api.github.com/users/rock-core/gists{/gist_id}","starred_url":"https://api.github.com/users/rock-core/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rock-core/subscriptions","organizations_url":"https://api.github.com/users/rock-core/orgs","repos_url":"https://api.github.com/users/rock-core/repos","events_url":"https://api.github.com/users/rock-core/events{/privacy}","received_events_url":"https://api.github.com/users/rock-core/received_events","type":"Organization","site_admin":false},"repo":{"id":19274613,"name":"base-scripts","full_name":"rock-core/base-scripts","owner":{"login":"rock-core","id":6654878,"avatar_url":"https://avatars.githubusercontent.com/u/6654878?v=3","gravatar_id":"","url":"https://api.github.com/users/rock-core","html_url":"https://github.com/rock-core","followers_url":"https://api.github.com/users/rock-core/followers","following_url":"https://api.github.com/users/rock-core/following{/other_user}","gists_url":"https://api.github.com/users/rock-core/gists{/gist_id}","starred_url":"https://api.github.com/users/rock-core/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rock-core/subscriptions","organizations_url":"https://api.github.com/users/rock-core/orgs","repos_url":"https://api.github.com/users/rock-core/repos","events_url":"https://api.github.com/users/rock-core/events{/privacy}","received_events_url":"https://api.github.com/users/rock-core/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rock-core/base-scripts","description":"Scripts to interact with a Rock installation","fork":false,"url":"https://api.github.com/repos/rock-core/base-scripts","forks_url":"https://api.github.com/repos/rock-core/base-scripts/forks","keys_url":"https://api.github.com/repos/rock-core/base-scripts/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rock-core/base-scripts/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rock-core/base-scripts/teams","hooks_url":"https://api.github.com/repos/rock-core/base-scripts/hooks","issue_events_url":"https://api.github.com/repos/rock-core/base-scripts/issues/events{/number}","events_url":"https://api.github.com/repos/rock-core/base-scripts/events","assignees_url":"https://api.github.com/repos/rock-core/base-scripts/assignees{/user}","branches_url":"https://api.github.com/repos/rock-core/base-scripts/branches{/branch}","tags_url":"https://api.github.com/repos/rock-core/base-scripts/tags","blobs_url":"https://api.github.com/repos/rock-core/base-scripts/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rock-core/base-scripts/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rock-core/base-scripts/git/refs{/sha}","trees_url":"https://api.github.com/repos/rock-core/base-scripts/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rock-core/base-scripts/statuses/{sha}","languages_url":"https://api.github.com/repos/rock-core/base-scripts/languages","stargazers_url":"https://api.github.com/repos/rock-core/base-scripts/stargazers","contributors_url":"https://api.github.com/repos/rock-core/base-scripts/contributors","subscribers_url":"https://api.github.com/repos/rock-core/base-scripts/subscribers","subscription_url":"https://api.github.com/repos/rock-core/base-scripts/subscription","commits_url":"https://api.github.com/repos/rock-core/base-scripts/commits{/sha}","git_commits_url":"https://api.github.com/repos/rock-core/base-scripts/git/commits{/sha}","comments_url":"https://api.github.com/repos/rock-core/base-scripts/comments{/number}","issue_comment_url":"https://api.github.com/repos/rock-core/base-scripts/issues/comments{/number}","contents_url":"https://api.github.com/repos/rock-core/base-scripts/contents/{+path}","compare_url":"https://api.github.com/repos/rock-core/base-scripts/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rock-core/base-scripts/merges","archive_url":"https://api.github.com/repos/rock-core/base-scripts/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rock-core/base-scripts/downloads","issues_url":"https://api.github.com/repos/rock-core/base-scripts/issues{/number}","pulls_url":"https://api.github.com/repos/rock-core/base-scripts/pulls{/number}","milestones_url":"https://api.github.com/repos/rock-core/base-scripts/milestones{/number}","notifications_url":"https://api.github.com/repos/rock-core/base-scripts/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rock-core/base-scripts/labels{/name}","releases_url":"https://api.github.com/repos/rock-core/base-scripts/releases{/id}","deployments_url":"https://api.github.com/repos/rock-core/base-scripts/deployments","created_at":"2014-04-29T11:50:14Z","updated_at":"2016-02-24T18:22:23Z","pushed_at":"2016-11-22T19:35:57Z","git_url":"git://github.com/rock-core/base-scripts.git","ssh_url":"git@github.com:rock-core/base-scripts.git","clone_url":"https://github.com/rock-core/base-scripts.git","svn_url":"https://github.com/rock-core/base-scripts","homepage":null,"size":299,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":5,"forks":5,"open_issues":5,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rock-core/base-scripts/pulls/30"},"html":{"href":"https://github.com/rock-core/base-scripts/pull/30"},"issue":{"href":"https://api.github.com/repos/rock-core/base-scripts/issues/30"},"comments":{"href":"https://api.github.com/repos/rock-core/base-scripts/issues/30/comments"},"review_comments":{"href":"https://api.github.com/repos/rock-core/base-scripts/pulls/30/comments"},"review_comment":{"href":"https://api.github.com/repos/rock-core/base-scripts/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rock-core/base-scripts/pulls/30/commits"},"statuses":{"href":"https://api.github.com/repos/rock-core/base-scripts/statuses/1313ac29c28165b5069da7a202a5000a3b6bd6d3"}}}}
{"actor":{"display_login":"2maz"}}