forked from X-Profiler/xprofiler
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
src: support dump node report (X-Profiler#24)
- Loading branch information
Showing
29 changed files
with
1,182 additions
and
39 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
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
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
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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#include "heap_statistics.h" | ||
|
||
#include "v8.h" | ||
|
||
namespace xprofiler { | ||
using v8::HeapSpaceStatistics; | ||
using v8::HeapStatistics; | ||
using v8::Isolate; | ||
|
||
void SetHeapStatistics(JSONWriter* writer) { | ||
Isolate* isolate = Isolate::GetCurrent(); | ||
HeapStatistics v8_heap_stats; | ||
isolate->GetHeapStatistics(&v8_heap_stats); | ||
|
||
writer->json_objectstart("heapStatistics"); | ||
writer->json_keyvalue("heapTotal", v8_heap_stats.total_heap_size()); | ||
writer->json_keyvalue("heapTotalCommitted", | ||
v8_heap_stats.total_physical_size()); | ||
writer->json_keyvalue("heapTotalUsed", v8_heap_stats.used_heap_size()); | ||
writer->json_keyvalue("heapTotalAvailable", | ||
v8_heap_stats.total_available_size()); | ||
writer->json_keyvalue("heapLimit", v8_heap_stats.heap_size_limit()); | ||
writer->json_objectend(); | ||
|
||
HeapSpaceStatistics v8_heap_space_stats; | ||
writer->json_arraystart("heapSpaceStatistics"); | ||
for (size_t i = 0; i < isolate->NumberOfHeapSpaces(); i++) { | ||
isolate->GetHeapSpaceStatistics(&v8_heap_space_stats, i); | ||
writer->json_start(); | ||
writer->json_keyvalue("name", v8_heap_space_stats.space_name()); | ||
writer->json_keyvalue("size", v8_heap_space_stats.space_size()); | ||
writer->json_keyvalue("committed", | ||
v8_heap_space_stats.physical_space_size()); | ||
writer->json_keyvalue("capacity", | ||
v8_heap_space_stats.space_used_size() + | ||
v8_heap_space_stats.space_available_size()); | ||
writer->json_keyvalue("used", v8_heap_space_stats.space_used_size()); | ||
writer->json_keyvalue("available", | ||
v8_heap_space_stats.space_available_size()); | ||
writer->json_end(); | ||
} | ||
writer->json_arrayend(); | ||
} | ||
} // namespace xprofiler |
Oops, something went wrong.