|
|
@@ -7,6 +7,8 @@
|
|
|
|
|
|
#include <math.h>
|
|
|
|
|
|
+#include <zlib.h>
|
|
|
+
|
|
|
//#define TRACK_OVERHEAD
|
|
|
|
|
|
struct profiler_snapshot {
|
|
|
@@ -1022,6 +1024,28 @@ bool profiler_snapshot_dump_csv(const profiler_snapshot_t *snap,
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+static void dump_csv_gzwrite(void *data, struct dstr *buffer)
|
|
|
+{
|
|
|
+ gzwrite(data, buffer->array, (unsigned)buffer->len);
|
|
|
+}
|
|
|
+
|
|
|
+bool profiler_snapshot_dump_csv_gz(const profiler_snapshot_t *snap,
|
|
|
+ const char *filename)
|
|
|
+{
|
|
|
+ FILE *f = os_fopen(filename, "wb");
|
|
|
+ if (!f)
|
|
|
+ return false;
|
|
|
+
|
|
|
+ gzFile gz = gzdopen(fileno(f), "wb");
|
|
|
+ if (!gz)
|
|
|
+ return false;
|
|
|
+
|
|
|
+ profiler_snapshot_dump(snap, dump_csv_gzwrite, gz);
|
|
|
+
|
|
|
+ gzclose_w(gz);
|
|
|
+ return true;
|
|
|
+}
|
|
|
+
|
|
|
size_t profiler_snapshot_num_roots(profiler_snapshot_t *snap)
|
|
|
{
|
|
|
return snap ? snap->roots.num : 0;
|