{"action":"created","comment":{"url":"https://api.github.com/repos/highfidelity/hifi/pulls/comments/23881140","id":23881140,"diff_hunk":"@@ -0,0 +1,56 @@\n+//\n+//  BandwidthRecorder.h\n+//\n+//  Created by Seth Alves on 2015-1-30\n+//  Copyright 2015 High Fidelity, Inc.\n+//\n+//  Based on code by Tobias Schwinger\n+//\n+//  Distributed under the Apache License, Version 2.0.\n+//  See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html\n+//\n+\n+\n+#ifndef hifi_BandwidthRecorder_h\n+#define hifi_BandwidthRecorder_h\n+\n+#include <QElapsedTimer>\n+\n+class BandwidthRecorder {\n+ public:\n+    BandwidthRecorder();\n+    ~BandwidthRecorder();\n+\n+    // keep track of data rate in one direction\n+    class Stream {\n+    public:\n+        Stream(float msToAverage = 3000.0f);\n+        void updateValue(double amount);\n+        double getValue() const { return _value; }\n+    private:\n+        double _value; // Current value.\n+        double _msToAverage; // Milliseconds to average.\n+        QElapsedTimer _prevTime; // Time of last feed.\n+    };\n+\n+    // keep track of data rate in two directions as well as units and style to use during display\n+    class Channel {\n+    public:\n+        Channel(char const* const caption, char const* unitCaption, double unitScale, unsigned colorRGBA);\n+        Stream input;\n+        Stream output;\n+        char const* const caption;\n+        char const* unitCaption;\n+        double unitScale;\n+        unsigned colorRGBA;\n+    };\n+\n+    // create the channels we keep track of\n+    Channel* audioChannel = new Channel(\"Audio\", \"Kbps\", 8000.0 / 1024.0, 0x33cc99ff);\n+    Channel* avatarsChannel = new Channel(\"Avatars\", \"Kbps\", 8000.0 / 1024.0, 0xffef40c0);\n+    Channel* octreeChannel = new Channel(\"Octree\", \"Kbps\", 8000.0 / 1024.0, 0xd0d0d0a0);\n+    Channel* metavoxelsChannel = new Channel(\"Metavoxels\", \"Kbps\", 8000.0 / 1024.0, 0xd0d0d0a0);\n+    Channel* totalChannel = new Channel(\"Total\", \"Kbps\", 8000.0 / 1024.0, 0xd0d0d0a0);\n+};","path":"interface/src/BandwidthRecorder.h","position":54,"original_position":54,"commit_id":"067deefeb6b7fd2b13c38f467d522d424880828d","original_commit_id":"067deefeb6b7fd2b13c38f467d522d424880828d","user":{"login":"AndrewMeadows","id":2186405,"avatar_url":"https://avatars.githubusercontent.com/u/2186405?v=3","gravatar_id":"","url":"https://api.github.com/users/AndrewMeadows","html_url":"https://github.com/AndrewMeadows","followers_url":"https://api.github.com/users/AndrewMeadows/followers","following_url":"https://api.github.com/users/AndrewMeadows/following{/other_user}","gists_url":"https://api.github.com/users/AndrewMeadows/gists{/gist_id}","starred_url":"https://api.github.com/users/AndrewMeadows/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AndrewMeadows/subscriptions","organizations_url":"https://api.github.com/users/AndrewMeadows/orgs","repos_url":"https://api.github.com/users/AndrewMeadows/repos","events_url":"https://api.github.com/users/AndrewMeadows/events{/privacy}","received_events_url":"https://api.github.com/users/AndrewMeadows/received_events","type":"User","site_admin":false},"body":"We're trying to abide by our coding standards.  Although you'll still see some ClassName::dataMember names in some old code we're trying to make sure all new code shows up like ClassName::_dataMember, so we need to change the class member names from \"foo\" to \"_foo\".\r\n\r\nAlso, create a const variable for the unitScale arguments in the initializers:\r\n\r\nconst double DEFAULT_UNIT_SCALE = 8000.0 / 1024.0;\r\nChannel* audioChannel = new Channel(\"Audio\", \"Kbps\", DEFAULT_UNIT_SCALE, 0x33cc99ff);\r\n\r\nFinally, you might also want to give the colors some names (we're supposed to try to keep magic numbers to a minimum):\r\n\r\nconst unsigned int AQUAMARINE = 0x33cc99ff;\r\nconst unsigned int SLIGHTLY_TRANSPARENT_LIGHT_GRAY = 0xd0d0d0a0;","created_at":"2015-01-30T23:43:56Z","updated_at":"2015-01-30T23:43:56Z","html_url":"https://github.com/highfidelity/hifi/pull/4206#discussion_r23881140","pull_request_url":"https://api.github.com/repos/highfidelity/hifi/pulls/4206","_links":{"self":{"href":"https://api.github.com/repos/highfidelity/hifi/pulls/comments/23881140"},"html":{"href":"https://github.com/highfidelity/hifi/pull/4206#discussion_r23881140"},"pull_request":{"href":"https://api.github.com/repos/highfidelity/hifi/pulls/4206"}}},"pull_request":{"url":"https://api.github.com/repos/highfidelity/hifi/pulls/4206","id":28399542,"html_url":"https://github.com/highfidelity/hifi/pull/4206","diff_url":"https://github.com/highfidelity/hifi/pull/4206.diff","patch_url":"https://github.com/highfidelity/hifi/pull/4206.patch","issue_url":"https://api.github.com/repos/highfidelity/hifi/issues/4206","number":4206,"state":"open","locked":false,"title":"Rework bandwidth meter dialog","user":{"login":"sethalves","id":1137072,"avatar_url":"https://avatars.githubusercontent.com/u/1137072?v=3","gravatar_id":"","url":"https://api.github.com/users/sethalves","html_url":"https://github.com/sethalves","followers_url":"https://api.github.com/users/sethalves/followers","following_url":"https://api.github.com/users/sethalves/following{/other_user}","gists_url":"https://api.github.com/users/sethalves/gists{/gist_id}","starred_url":"https://api.github.com/users/sethalves/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sethalves/subscriptions","organizations_url":"https://api.github.com/users/sethalves/orgs","repos_url":"https://api.github.com/users/sethalves/repos","events_url":"https://api.github.com/users/sethalves/events{/privacy}","received_events_url":"https://api.github.com/users/sethalves/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-01-30T22:41:35Z","updated_at":"2015-01-30T23:43:56Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a3a4ba4109c41b597b2059131be25ef4c78d02d6","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/highfidelity/hifi/pulls/4206/commits","review_comments_url":"https://api.github.com/repos/highfidelity/hifi/pulls/4206/comments","review_comment_url":"https://api.github.com/repos/highfidelity/hifi/pulls/comments/{number}","comments_url":"https://api.github.com/repos/highfidelity/hifi/issues/4206/comments","statuses_url":"https://api.github.com/repos/highfidelity/hifi/statuses/067deefeb6b7fd2b13c38f467d522d424880828d","head":{"label":"sethalves:rework-bandwidth-meter","ref":"rework-bandwidth-meter","sha":"067deefeb6b7fd2b13c38f467d522d424880828d","user":{"login":"sethalves","id":1137072,"avatar_url":"https://avatars.githubusercontent.com/u/1137072?v=3","gravatar_id":"","url":"https://api.github.com/users/sethalves","html_url":"https://github.com/sethalves","followers_url":"https://api.github.com/users/sethalves/followers","following_url":"https://api.github.com/users/sethalves/following{/other_user}","gists_url":"https://api.github.com/users/sethalves/gists{/gist_id}","starred_url":"https://api.github.com/users/sethalves/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sethalves/subscriptions","organizations_url":"https://api.github.com/users/sethalves/orgs","repos_url":"https://api.github.com/users/sethalves/repos","events_url":"https://api.github.com/users/sethalves/events{/privacy}","received_events_url":"https://api.github.com/users/sethalves/received_events","type":"User","site_admin":false},"repo":{"id":30046830,"name":"hifi","full_name":"sethalves/hifi","owner":{"login":"sethalves","id":1137072,"avatar_url":"https://avatars.githubusercontent.com/u/1137072?v=3","gravatar_id":"","url":"https://api.github.com/users/sethalves","html_url":"https://github.com/sethalves","followers_url":"https://api.github.com/users/sethalves/followers","following_url":"https://api.github.com/users/sethalves/following{/other_user}","gists_url":"https://api.github.com/users/sethalves/gists{/gist_id}","starred_url":"https://api.github.com/users/sethalves/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sethalves/subscriptions","organizations_url":"https://api.github.com/users/sethalves/orgs","repos_url":"https://api.github.com/users/sethalves/repos","events_url":"https://api.github.com/users/sethalves/events{/privacy}","received_events_url":"https://api.github.com/users/sethalves/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sethalves/hifi","description":"Open, decentralized virtual worlds using sensors to control avatars and dynamically assigned devices as servers.  San Francisco based startup, we are hiring: http://highfidelity.io/jobs  Documentation at http://docs.highfidelity.io  Contribute by reporting bugs & doing jobs on http://worklist.net","fork":true,"url":"https://api.github.com/repos/sethalves/hifi","forks_url":"https://api.github.com/repos/sethalves/hifi/forks","keys_url":"https://api.github.com/repos/sethalves/hifi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sethalves/hifi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sethalves/hifi/teams","hooks_url":"https://api.github.com/repos/sethalves/hifi/hooks","issue_events_url":"https://api.github.com/repos/sethalves/hifi/issues/events{/number}","events_url":"https://api.github.com/repos/sethalves/hifi/events","assignees_url":"https://api.github.com/repos/sethalves/hifi/assignees{/user}","branches_url":"https://api.github.com/repos/sethalves/hifi/branches{/branch}","tags_url":"https://api.github.com/repos/sethalves/hifi/tags","blobs_url":"https://api.github.com/repos/sethalves/hifi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sethalves/hifi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sethalves/hifi/git/refs{/sha}","trees_url":"https://api.github.com/repos/sethalves/hifi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sethalves/hifi/statuses/{sha}","languages_url":"https://api.github.com/repos/sethalves/hifi/languages","stargazers_url":"https://api.github.com/repos/sethalves/hifi/stargazers","contributors_url":"https://api.github.com/repos/sethalves/hifi/contributors","subscribers_url":"https://api.github.com/repos/sethalves/hifi/subscribers","subscription_url":"https://api.github.com/repos/sethalves/hifi/subscription","commits_url":"https://api.github.com/repos/sethalves/hifi/commits{/sha}","git_commits_url":"https://api.github.com/repos/sethalves/hifi/git/commits{/sha}","comments_url":"https://api.github.com/repos/sethalves/hifi/comments{/number}","issue_comment_url":"https://api.github.com/repos/sethalves/hifi/issues/comments/{number}","contents_url":"https://api.github.com/repos/sethalves/hifi/contents/{+path}","compare_url":"https://api.github.com/repos/sethalves/hifi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sethalves/hifi/merges","archive_url":"https://api.github.com/repos/sethalves/hifi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sethalves/hifi/downloads","issues_url":"https://api.github.com/repos/sethalves/hifi/issues{/number}","pulls_url":"https://api.github.com/repos/sethalves/hifi/pulls{/number}","milestones_url":"https://api.github.com/repos/sethalves/hifi/milestones{/number}","notifications_url":"https://api.github.com/repos/sethalves/hifi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sethalves/hifi/labels{/name}","releases_url":"https://api.github.com/repos/sethalves/hifi/releases{/id}","created_at":"2015-01-29T23:37:31Z","updated_at":"2015-01-30T22:41:07Z","pushed_at":"2015-01-30T23:23:45Z","git_url":"git://github.com/sethalves/hifi.git","ssh_url":"git@github.com:sethalves/hifi.git","clone_url":"https://github.com/sethalves/hifi.git","svn_url":"https://github.com/sethalves/hifi","homepage":"","size":129117,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"highfidelity:master","ref":"master","sha":"53534cea61d2df599210c27a9eb3737fb374e6d0","user":{"login":"highfidelity","id":1565370,"avatar_url":"https://avatars.githubusercontent.com/u/1565370?v=3","gravatar_id":"","url":"https://api.github.com/users/highfidelity","html_url":"https://github.com/highfidelity","followers_url":"https://api.github.com/users/highfidelity/followers","following_url":"https://api.github.com/users/highfidelity/following{/other_user}","gists_url":"https://api.github.com/users/highfidelity/gists{/gist_id}","starred_url":"https://api.github.com/users/highfidelity/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/highfidelity/subscriptions","organizations_url":"https://api.github.com/users/highfidelity/orgs","repos_url":"https://api.github.com/users/highfidelity/repos","events_url":"https://api.github.com/users/highfidelity/events{/privacy}","received_events_url":"https://api.github.com/users/highfidelity/received_events","type":"Organization","site_admin":false},"repo":{"id":5372872,"name":"hifi","full_name":"highfidelity/hifi","owner":{"login":"highfidelity","id":1565370,"avatar_url":"https://avatars.githubusercontent.com/u/1565370?v=3","gravatar_id":"","url":"https://api.github.com/users/highfidelity","html_url":"https://github.com/highfidelity","followers_url":"https://api.github.com/users/highfidelity/followers","following_url":"https://api.github.com/users/highfidelity/following{/other_user}","gists_url":"https://api.github.com/users/highfidelity/gists{/gist_id}","starred_url":"https://api.github.com/users/highfidelity/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/highfidelity/subscriptions","organizations_url":"https://api.github.com/users/highfidelity/orgs","repos_url":"https://api.github.com/users/highfidelity/repos","events_url":"https://api.github.com/users/highfidelity/events{/privacy}","received_events_url":"https://api.github.com/users/highfidelity/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/highfidelity/hifi","description":"Open, decentralized virtual worlds using sensors to control avatars and dynamically assigned devices as servers.  San Francisco based startup, we are hiring: http://highfidelity.io/jobs  Documentation at http://docs.highfidelity.io  Contribute by reporting bugs & doing jobs on http://worklist.net","fork":false,"url":"https://api.github.com/repos/highfidelity/hifi","forks_url":"https://api.github.com/repos/highfidelity/hifi/forks","keys_url":"https://api.github.com/repos/highfidelity/hifi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/highfidelity/hifi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/highfidelity/hifi/teams","hooks_url":"https://api.github.com/repos/highfidelity/hifi/hooks","issue_events_url":"https://api.github.com/repos/highfidelity/hifi/issues/events{/number}","events_url":"https://api.github.com/repos/highfidelity/hifi/events","assignees_url":"https://api.github.com/repos/highfidelity/hifi/assignees{/user}","branches_url":"https://api.github.com/repos/highfidelity/hifi/branches{/branch}","tags_url":"https://api.github.com/repos/highfidelity/hifi/tags","blobs_url":"https://api.github.com/repos/highfidelity/hifi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/highfidelity/hifi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/highfidelity/hifi/git/refs{/sha}","trees_url":"https://api.github.com/repos/highfidelity/hifi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/highfidelity/hifi/statuses/{sha}","languages_url":"https://api.github.com/repos/highfidelity/hifi/languages","stargazers_url":"https://api.github.com/repos/highfidelity/hifi/stargazers","contributors_url":"https://api.github.com/repos/highfidelity/hifi/contributors","subscribers_url":"https://api.github.com/repos/highfidelity/hifi/subscribers","subscription_url":"https://api.github.com/repos/highfidelity/hifi/subscription","commits_url":"https://api.github.com/repos/highfidelity/hifi/commits{/sha}","git_commits_url":"https://api.github.com/repos/highfidelity/hifi/git/commits{/sha}","comments_url":"https://api.github.com/repos/highfidelity/hifi/comments{/number}","issue_comment_url":"https://api.github.com/repos/highfidelity/hifi/issues/comments/{number}","contents_url":"https://api.github.com/repos/highfidelity/hifi/contents/{+path}","compare_url":"https://api.github.com/repos/highfidelity/hifi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/highfidelity/hifi/merges","archive_url":"https://api.github.com/repos/highfidelity/hifi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/highfidelity/hifi/downloads","issues_url":"https://api.github.com/repos/highfidelity/hifi/issues{/number}","pulls_url":"https://api.github.com/repos/highfidelity/hifi/pulls{/number}","milestones_url":"https://api.github.com/repos/highfidelity/hifi/milestones{/number}","notifications_url":"https://api.github.com/repos/highfidelity/hifi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/highfidelity/hifi/labels{/name}","releases_url":"https://api.github.com/repos/highfidelity/hifi/releases{/id}","created_at":"2012-08-10T18:26:22Z","updated_at":"2015-01-30T22:55:54Z","pushed_at":"2015-01-30T21:15:57Z","git_url":"git://github.com/highfidelity/hifi.git","ssh_url":"git@github.com:highfidelity/hifi.git","clone_url":"https://github.com/highfidelity/hifi.git","svn_url":"https://github.com/highfidelity/hifi","homepage":"","size":178366,"stargazers_count":225,"watchers_count":225,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":130,"mirror_url":null,"open_issues_count":52,"forks":130,"open_issues":52,"watchers":225,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/highfidelity/hifi/pulls/4206"},"html":{"href":"https://github.com/highfidelity/hifi/pull/4206"},"issue":{"href":"https://api.github.com/repos/highfidelity/hifi/issues/4206"},"comments":{"href":"https://api.github.com/repos/highfidelity/hifi/issues/4206/comments"},"review_comments":{"href":"https://api.github.com/repos/highfidelity/hifi/pulls/4206/comments"},"review_comment":{"href":"https://api.github.com/repos/highfidelity/hifi/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/highfidelity/hifi/pulls/4206/commits"},"statuses":{"href":"https://api.github.com/repos/highfidelity/hifi/statuses/067deefeb6b7fd2b13c38f467d522d424880828d"}}}}