-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PR-URL: #133 Reviewed-BY: hyj1991 <[email protected]>
- Loading branch information
1 parent
ae6ab8d
commit f78cd6a
Showing
8 changed files
with
107 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,21 @@ | ||
#include "heap_profiler.h" | ||
|
||
#include "heap_snapshot.h" | ||
#include "util.h" | ||
#include "xpf_v8.h" | ||
|
||
namespace xprofiler { | ||
using Nan::HandleScope; | ||
using v8::HeapSnapshot; | ||
using v8::Isolate; | ||
|
||
HeapProfiler::HeapProfiler() {} | ||
HeapProfiler::~HeapProfiler() {} | ||
void DeleteHeapSnapshot(const v8::HeapSnapshot* snapshot) { | ||
const_cast<v8::HeapSnapshot*>(snapshot)->Delete(); | ||
} | ||
|
||
void HeapProfiler::TakeSnapshot(string filename) { | ||
Isolate *isolate = Isolate::GetCurrent(); | ||
HandleScope scope; | ||
const HeapSnapshot *snap = isolate->GetHeapProfiler()->TakeHeapSnapshot(); | ||
Snapshot::Serialize(snap, filename); | ||
void HeapProfiler::TakeSnapshot(v8::Isolate* isolate, std::string filename) { | ||
HandleScope scope(isolate); | ||
HeapSnapshotPointer snap = | ||
HeapSnapshotPointer(isolate->GetHeapProfiler()->TakeHeapSnapshot()); | ||
HeapSnapshot::Serialize(std::move(snap), filename); | ||
} | ||
|
||
} // namespace xprofiler |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,20 @@ | ||
#ifndef _SRC_COMMANDS_HEAPDUMP_HEAP_PROFILER_H | ||
#define _SRC_COMMANDS_HEAPDUMP_HEAP_PROFILER_H | ||
#ifndef XPROFILER_SRC_COMMANDS_HEAPDUMP_HEAP_PROFILER_H | ||
#define XPROFILER_SRC_COMMANDS_HEAPDUMP_HEAP_PROFILER_H | ||
|
||
#include "nan.h" | ||
#include "util.h" | ||
#include "v8-profiler.h" | ||
|
||
namespace xprofiler { | ||
using std::string; | ||
void DeleteHeapSnapshot(const v8::HeapSnapshot* snapshot); | ||
|
||
using HeapSnapshotPointer = | ||
DeleteFnPtr<const v8::HeapSnapshot, DeleteHeapSnapshot>; | ||
|
||
class HeapProfiler { | ||
public: | ||
HeapProfiler(); | ||
virtual ~HeapProfiler(); | ||
static void TakeSnapshot(string filename); | ||
static void TakeSnapshot(v8::Isolate* isolate, std::string filename); | ||
}; | ||
} // namespace xprofiler | ||
|
||
#endif // NODE_HEAP_PROFILER_H | ||
#endif /* XPROFILER_SRC_COMMANDS_HEAPDUMP_HEAP_PROFILER_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,14 @@ | ||
#ifndef _SRC_COMMANDS_HEAPDUMP_HEAP_SNAPSHOT_H | ||
#define _SRC_COMMANDS_HEAPDUMP_HEAP_SNAPSHOT_H | ||
#ifndef XPROFILER_SRC_COMMANDS_HEAPDUMP_HEAP_SNAPSHOT_H | ||
#define XPROFILER_SRC_COMMANDS_HEAPDUMP_HEAP_SNAPSHOT_H | ||
|
||
#include "heap_profiler.h" | ||
#include "v8-profiler.h" | ||
|
||
namespace xprofiler { | ||
using std::string; | ||
using v8::HeapSnapshot; | ||
|
||
class Snapshot { | ||
class HeapSnapshot { | ||
public: | ||
static void Serialize(const HeapSnapshot *profile, string filename); | ||
static void Serialize(HeapSnapshotPointer profile, std::string filename); | ||
}; | ||
} // namespace xprofiler | ||
#endif // NODE_SNAPSHOT_ | ||
|
||
#endif /* XPROFILER_SRC_COMMANDS_HEAPDUMP_HEAP_SNAPSHOT_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,16 @@ | ||
#ifndef _SRC_COMMANDS_HEAPPROFILER_SAMPLING_HEAP_PROFILER_H | ||
#define _SRC_COMMANDS_HEAPPROFILER_SAMPLING_HEAP_PROFILER_H | ||
#ifndef XPROFILER_SRC_COMMANDS_HEAPPROFILER_SAMPLING_HEAP_PROFILER_H | ||
#define XPROFILER_SRC_COMMANDS_HEAPPROFILER_SAMPLING_HEAP_PROFILER_H | ||
|
||
#include "nan.h" | ||
#include "v8-profiler.h" | ||
|
||
namespace xprofiler { | ||
using std::string; | ||
|
||
class SamplingHeapProfile { | ||
class SamplingHeapProfiler final { | ||
public: | ||
SamplingHeapProfile(); | ||
virtual ~SamplingHeapProfile(); | ||
static void StartSamplingHeapProfiling(); | ||
static void StopSamplingHeapProfiling(string filename); | ||
static void StartSamplingHeapProfiling(v8::Isolate* isolate); | ||
static void StopSamplingHeapProfiling(v8::Isolate* isolate, | ||
std::string filename); | ||
}; | ||
|
||
} // namespace xprofiler | ||
#endif | ||
#endif /* XPROFILER_SRC_COMMANDS_HEAPPROFILER_SAMPLING_HEAP_PROFILER_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters