Skip to content

Instantly share code, notes, and snippets.

View aalexand's full-sized avatar

Alexey Alexandrov aalexand

View GitHub Profile
const heapProfile = require('heap-profile');
heapProfile.start({sampleIntervalBytes: 32 * 1024, stackDepth: 128});
function totalHeapSize(n) {
let size = 0;
for (let a of n.allocations) {
size += a.size * a.count;
}
for (let ch of n.children) {
size += totalHeapSize(ch);
#include <cstdio>
#include <cassert>
#include <vector>
#include <utility>
#include <algorithm>
#include <climits>
using namespace std;
class Node {
public: