packages feed

profiteur 0.1.2.2 → 0.2.0.0

raw patch · 11 files changed

+161/−100 lines, 11 filesdep ~filepath

Dependency ranges changed: filepath

Files

CHANGELOG view
@@ -1,3 +1,6 @@+- 0.2.0.0+    * Show individual time/alloc as separate nodes+ - 0.1.2.2     * Loosen `text` dependency 
data/js/cost-centre-node.js view
@@ -1,33 +1,22 @@-CostCentreNode.prototype = new Model();+CostCentreNode.prototype = new Node(); CostCentreNode.prototype.constructor = CostCentreNode;  function CostCentreNode(prof, selection, sorting, parent, id) {-    Model.call(this);--    this.prof      = prof;-    this.sorting   = sorting;-    this.parent    = parent;-    this.id        = id;-    this.data      = prof.nodes[id];-    this.expanded  = false;-    this.children  = [];-    this.selection = selection;--    sorting.addChangeListener(this);+    Node.call(this, prof, selection, sorting, parent, id); }  CostCentreNode.prototype.isExpandable = function() {-    return this.data.children.length > 0;-};--CostCentreNode.prototype.toggleExpanded = function() {-    this.setExpanded(!this.expanded);+    return true; };  CostCentreNode.prototype.computeChildren = function() {     var _this = this;      if (_this.expanded && _this.children.length <= 0) {+        _this.children.push(new IndividualNode(+                _this.prof, _this.selection, _this.sorting,+                _this.parent, _this.id));+         for (var i = 0; i < _this.data.children.length; i++) {             _this.children.push(new CostCentreNode(                     _this.prof, _this.selection, _this.sorting,@@ -42,77 +31,10 @@     }); }; -CostCentreNode.prototype.setExpanded = function(expanded) {-    var _this = this;--    if (_this.expanded === expanded) return;--    _this.expanded = expanded;-    _this.computeChildren();--    _this.triggerChange();-};--CostCentreNode.prototype.forChildren = function(f) {-    for (var i = 0; i < this.children.length; i++) {-        this.children[i].forChildren(f);-        f(this.children[i]);-    }-};--CostCentreNode.prototype.getCanonicalName = function() {-    return this.data.name.canonical;-};--CostCentreNode.prototype.getFullName = function() {-    return this.data.name.module + '.' + this.data.name.canonical;-};--CostCentreNode.prototype.getColor = function() {-    var hash = 5381;-    var str  = this.getFullName();-    for (var i = 0; i < str.length; i++) {-        hash = (hash << 5) + hash + str.charCodeAt(i);-    }--    hash = hash % 0xffffff;-    var r = (hash & 0xff0000) >> 16;-    var g = (hash & 0x00ff00) >> 8;-    var b = (hash & 0x0000ff);--    r = (r) / 2;-    g = (g) / 2;-    b = (b) / 2;--    function hex2(x) {-        var str = x.toString(16);-        if (str.length < 2) {-            for (var i = 0; i < 2 - str.length; i++) {-                str = '0' + str;-            }-        }-        return str;-    }--    return '#' +-        hex2(Math.round(r)) +-        hex2(Math.round(g)) +-        hex2(Math.round(b));-};--CostCentreNode.prototype.getCost = function() {-    return this.sorting.getCost(this);-};--CostCentreNode.prototype.isSelected = function() {-    return this == this.selection.getSelectedNode();-};--CostCentreNode.prototype.select = function() {-    this.selection.setSelectedNode(this);+CostCentreNode.prototype.getTime = function() {+    return this.data.info.inheritedTime; }; -CostCentreNode.prototype.onChange = function(sorting) {-    this.computeChildren();-    this.triggerChange();+CostCentreNode.prototype.getAlloc = function() {+    return this.data.info.inheritedAlloc; };
+ data/js/individual-node.js view
@@ -0,0 +1,24 @@+IndividualNode.prototype = new Node();+IndividualNode.prototype.constructor = IndividualNode;++function IndividualNode(prof, selection, sorting, parent, id) {+    Node.call(this, prof, selection, sorting, parent, id);++    this.id = id + '.individual';+}++IndividualNode.prototype.isExpandable = function() {+    return false;+};++IndividualNode.prototype.getCanonicalName = function() {+    return '(indiv)';+};++IndividualNode.prototype.getTime = function() {+    return this.data.info.individualTime;+};++IndividualNode.prototype.getAlloc = function() {+    return this.data.info.individualAlloc;+};
+ data/js/node.js view
@@ -0,0 +1,105 @@+Node.prototype = new Model();+Node.prototype.constructor = Node;++function Node(prof, selection, sorting, parent, id) {+    Model.call(this);++    this.prof      = prof;+    this.sorting   = sorting;+    this.parent    = parent;+    this.id        = id;+    this.data      = prof ? prof.nodes[id] : undefined;+    this.expanded  = false;+    this.children  = [];+    this.selection = selection;++    if (sorting) sorting.addChangeListener(this);+}++Node.prototype.isExpandable = function() {+    return false;+};++Node.prototype.toggleExpanded = function() {+    this.setExpanded(!this.expanded);+};++Node.prototype.computeChildren = function() {+    return;+};++Node.prototype.setExpanded = function(expanded) {+    var _this = this;++    if (_this.expanded === expanded) return;++    _this.expanded = expanded;+    _this.computeChildren();++    _this.triggerChange();+};++Node.prototype.getCanonicalName = function() {+    return this.data.name.canonical;+};++Node.prototype.getFullName = function() {+    return this.data.name.module + '.' + this.getCanonicalName();+};++Node.prototype.getColor = function() {+    var hash = 5381;+    var str  = this.data.name.module + '.' + this.data.name.canonical;+    for (var i = 0; i < str.length; i++) {+        hash = (hash << 5) + hash + str.charCodeAt(i);+    }++    hash = hash % 0xffffff;+    var r = (hash & 0xff0000) >> 16;+    var g = (hash & 0x00ff00) >> 8;+    var b = (hash & 0x0000ff);++    r = (r) / 2;+    g = (g) / 2;+    b = (b) / 2;++    function hex2(x) {+        var str = x.toString(16);+        if (str.length < 2) {+            for (var i = 0; i < 2 - str.length; i++) {+                str = '0' + str;+            }+        }+        return str;+    }++    return '#' ++        hex2(Math.round(r)) ++        hex2(Math.round(g)) ++        hex2(Math.round(b));+};++Node.prototype.getCost = function() {+    return this.sorting.getCost(this);+};++Node.prototype.getTime = function() {+    return 0;+};++Node.prototype.getAlloc = function() {+    return 0;+};++Node.prototype.isSelected = function() {+    return this == this.selection.getSelectedNode();+};++Node.prototype.select = function() {+    this.selection.setSelectedNode(this);+};++Node.prototype.onChange = function(sorting) {+    this.computeChildren();+    this.triggerChange();+};
data/js/sorting.js view
@@ -5,13 +5,13 @@     'by-time': {         name:    'View by time',         getCost: function(node) {-            return node.data.info.inheritedTime;+            return node.getTime();         }     },     'by-alloc': {         name:    'View by alloc',         getCost: function(node) {-            return node.data.info.inheritedAlloc;+            return node.getAlloc();         }     } };
data/js/tree-browser.js view
@@ -88,7 +88,8 @@         _this.container.append(_this.elements[node.id]);         _this.renderNode(_this.elements[node.id], node);         node.addChangeListener(_this);-    } else if (source instanceof CostCentreNode) {+    } else if ((source instanceof CostCentreNode) ||+            (source instanceof IndividualNode)) {         var element = _this.elements[source.id];          if (!element) return;  // Invisible source changed what?
data/js/tree-map.js view
@@ -240,7 +240,8 @@         _this.rects[node.id] = _this.mkRootRect();         _this.render();         node.addChangeListener(this);-    } else if (source instanceof CostCentreNode) {+    } else if ((source instanceof CostCentreNode) ||+            (source instanceof IndividualNode)) {         _this.render();         for (var i = 0; i < source.children.length; i++) {             source.children[i].addChangeListener(this);
profiteur.cabal view
@@ -1,5 +1,5 @@ Name:                profiteur-Version:             0.1.2.2+Version:             0.2.0.0 Synopsis:            Treemap visualiser for GHC prof files Description:         Treemap visualiser for GHC prof files Homepage:            http://github.com/jaspervdj/profiteur@@ -20,8 +20,10 @@   data/html/body.html   data/js/cost-centre-node.js   data/js/details.js+  data/js/individual-node.js   data/js/main.js   data/js/model.js+  data/js/node.js   data/js/resizing-canvas.js   data/js/selection.js   data/js/sorting.js@@ -50,6 +52,6 @@     attoparsec           >= 0.10 && < 0.13,     bytestring           >= 0.9  && < 0.11,     text                 >= 0.11 && < 1.3,-    filepath             >= 1.3  && < 1.4,+    filepath             >= 1.3  && < 1.5,     unordered-containers >= 0.2  && < 0.3,     vector               >= 0.10 && < 0.11
src/Main.hs view
@@ -56,6 +56,8 @@     includeJs h "data/js/unicode.js"     includeJs h "data/js/model.js"     includeJs h "data/js/resizing-canvas.js"+    includeJs h "data/js/node.js"+    includeJs h "data/js/individual-node.js"     includeJs h "data/js/cost-centre-node.js"     includeJs h "data/js/selection.js"     includeJs h "data/js/zoom.js"
src/Profiteur/Core.hs view
@@ -28,7 +28,7 @@ -------------------------------------------------------------------------------- data Prof = Prof     { pNodes :: !CostCentreMap-    , pRoot  :: !Int+    , pRoot  :: !T.Text     } deriving (Show)  @@ -58,14 +58,14 @@   where     go :: CostCentreMap -> CostCentreNode -> CostCentreMap     go ccm !ccn =-        HMS.insert (T.pack $ show $ ccnId ccn) ccn $+        HMS.insert (ccnId ccn) ccn $         V.foldl' go ccm (ccnChildren ccn)   -------------------------------------------------------------------------------- data CostCentreNode = CostCentreNode     { ccnName     :: !Name-    , ccnId       :: !Int+    , ccnId       :: !T.Text     , ccnInfo     :: !CostCentreInfo     , ccnChildren :: !(Vector CostCentreNode)     } deriving (Show)
src/Profiteur/Parser.hs view
@@ -8,9 +8,10 @@ -------------------------------------------------------------------------------- import           Control.Applicative              ((<$>)) import           Control.Monad                    (replicateM_)-import           Data.Attoparsec                  as AP+import           Data.Attoparsec.ByteString       as AP import           Data.Attoparsec.ByteString.Char8 as AP8 import           Data.Text                        (Text)+import qualified Data.Text                        as T import qualified Data.Text.Encoding               as T import qualified Data.Vector                      as V @@ -38,7 +39,7 @@     skipHorizontalSpace     module' <- identifier     skipHorizontalSpace-    id' <- AP8.decimal+    id' <- T.pack . show <$> (AP8.decimal :: AP.Parser Int)      skipHorizontalSpace     entries <- AP8.decimal