Permalink
Browse files

Cleans up a bit code formating to make it more readable.

  • Loading branch information...
1 parent 3523d2d commit 995495186e15cf1810fd41111e873ff892b51dea @c4milo committed Apr 1, 2012
Showing with 48 additions and 41 deletions.
  1. +15 −15 graph_edge.cc
  2. +18 −18 graph_node.cc
  3. +9 −2 profiler.cc
  4. +6 −6 readme.md
View
@@ -21,29 +21,29 @@ Handle<Value> GraphEdge::GetType(Local<String> property, const AccessorInfo& inf
Local<Object> self = info.Holder();
void* ptr = self->GetPointerFromInternalField(0);
int32_t type = static_cast<int32_t>(static_cast<HeapGraphEdge*>(ptr)->GetType());
+
Local<String> t;
switch(type) {
case HeapGraphEdge::kContextVariable :
- t = String::New("ContextVariable");
- break;
+ t = String::New("ContextVariable");
+ break;
case HeapGraphEdge::kElement :
- t = String::New("Element");
- break;
+ t = String::New("Element");
+ break;
case HeapGraphEdge::kProperty :
- t = String::New("Property");
- break;
+ t = String::New("Property");
+ break;
case HeapGraphEdge::kInternal :
- t = String::New("Internal");
- break;
+ t = String::New("Internal");
+ break;
case HeapGraphEdge::kHidden :
- t = String::New("Hidden");
- break;
+ t = String::New("Hidden");
+ break;
case HeapGraphEdge::kShortcut :
- t = String::New("Shortcut");
- break;
+ t = String::New("Shortcut");
+ break;
default:
- t = String::New("Unknown");
- break;
+ t = String::New("Unknown");
}
return scope.Close(t);
}
@@ -88,4 +88,4 @@ Handle<Value> GraphEdge::New(const HeapGraphEdge* edge) {
return scope.Close(obj);
}
}
-}
+} //namespace nodex
View
@@ -31,31 +31,31 @@ Handle<Value> GraphNode::GetType(Local<String> property, const AccessorInfo& inf
Local<String> t;
switch(type) {
case HeapGraphNode::kArray :
- t = String::New("Array");
- break;
+ t = String::New("Array");
+ break;
case HeapGraphNode::kString :
- t = String::New("String");
- break;
+ t = String::New("String");
+ break;
case HeapGraphNode::kObject :
- t = String::New("Object");
- break;
+ t = String::New("Object");
+ break;
case HeapGraphNode::kCode :
- t = String::New("Code");
- break;
+ t = String::New("Code");
+ break;
case HeapGraphNode::kClosure :
- t = String::New("Closure");
- break;
+ t = String::New("Closure");
+ break;
case HeapGraphNode::kRegExp :
- t = String::New("RegExp");
- break;
+ t = String::New("RegExp");
+ break;
case HeapGraphNode::kHeapNumber :
- t = String::New("HeapNumber");
- break;
- case HeapGraphNode::kNative :
- t = String::New("Native");
+ t = String::New("HeapNumber");
+ break;
+ case HeapGraphNode::kNative :
+ t = String::New("Native");
+ break;
default:
- t = String::New("Hidden");
- break;
+ t = String::New("Hidden");
}
return scope.Close(t);
}
View
@@ -1,4 +1,3 @@
-#include <v8.h>
#include <v8-profiler.h>
#include <node.h>
#include "snapshot.h"
@@ -11,15 +10,20 @@ using namespace nodex;
static Handle<Value> TakeSnapshot(const Arguments& args) {
HandleScope scope;
Local<String> title = String::New("");
- int32_t len = args.Length();
+ uint32_t len = args.Length();
+
HeapSnapshot::Type mode = HeapSnapshot::kFull;
+
if (len > 0) {
title = args[0]->ToString();
}
+
if (len > 1 && args[1]->IsInt32()) {
mode = static_cast<HeapSnapshot::Type>(args[1]->Int32Value());
}
+
const HeapSnapshot* snapshot = HeapProfiler::TakeSnapshot(title, mode);
+
return scope.Close(Snapshot::New(snapshot));
}
@@ -32,6 +36,7 @@ static Handle<Value> GetSnapshot(const Arguments& args) {
}
int32_t index = args[0]->Int32Value();
const HeapSnapshot* snapshot = HeapProfiler::GetSnapshot(index);
+
return scope.Close(Snapshot::New(snapshot));
}
@@ -40,8 +45,10 @@ static Handle<Value> FindSnapshot(const Arguments& args) {
if (args.Length() < 1) {
return ThrowException(Exception::Error(String::New("No uid specified")));
}
+
uint32_t uid = args[0]->Uint32Value();
const HeapSnapshot* snapshot = HeapProfiler::FindSnapshot(uid);
+
return scope.Close(Snapshot::New(snapshot));
}
View
@@ -3,18 +3,18 @@ profiler and integration with [node-inspector](http://github.com/dannycoates/nod
## Installation
- npm install v8-profiler
+ npm install v8-profiler
## Usage
- var profiler = require('v8-profiler');
+ var profiler = require('v8-profiler');
## API
- var snapshot = profiler.takeSnapshot([name]) //takes a heap snapshot
-
- profiler.startProfiling([name]) //begin cpu profiling
- var cpuProfile = profiler.stopProfiling([name]) //finish cpu profiling
+ var snapshot = profiler.takeSnapshot([name]) //takes a heap snapshot
+
+ profiler.startProfiling([name]) //begin cpu profiling
+ var cpuProfile = profiler.stopProfiling([name]) //finish cpu profiling
## node-inspector

0 comments on commit 9954951

Please sign in to comment.