github.com/pyroscope-io/pyroscope@v0.37.3-0.20230725203016-5f6947968bd0/webapp/javascript/components/ExportData.spec.tsx (about)

     1  import React from 'react';
     2  // import { SimpleSingle as TestData } from '@utils/testData';
     3  import { render, screen } from '@testing-library/react';
     4  import { Profile } from '@pyroscope/models/src';
     5  import ExportData, { getFilename } from './ExportData';
     6  
     7  describe('ExportData', () => {
     8    it('fails if theres not a single export mode', () => {
     9      // ignore console.error since jsdom will complain
    10      jest.spyOn(global.console, 'error').mockImplementation(() => jest.fn());
    11  
    12      expect(() => render(<ExportData flamebearer={{} as any} />)).toThrow();
    13  
    14      jest.restoreAllMocks();
    15    });
    16  
    17    // For these tests, since the code actually navigates to a url
    18    // We took the easy route and just test for the button presence
    19    describe('assert button presence', () => {
    20      it('supports a download JSON button', () => {
    21        render(<ExportData exportJSON flamebearer={TestData} />);
    22        screen.getByRole('button', { name: /json/i });
    23      });
    24  
    25      it('supports a download pprof button', () => {
    26        render(<ExportData exportPprof flamebearer={TestData} />);
    27        screen.getByRole('button', { name: /pprof/i });
    28      });
    29  
    30      it('supports a download png button', () => {
    31        render(<ExportData exportPNG flamebearer={TestData} />);
    32        screen.getByRole('button', { name: /png/i });
    33      });
    34  
    35      it('supports a download html button', () => {
    36        render(<ExportData exportHTML flamebearer={TestData} />);
    37        screen.getByRole('button', { name: /html/i });
    38      });
    39    });
    40  
    41    describe('filename', () => {
    42      it('generates a fullname', () => {
    43        expect(
    44          getFilename(
    45            'pyroscope.server.alloc_objects',
    46            TestData.metadata.startTime,
    47            TestData.metadata.endTime
    48          )
    49        ).toBe(
    50          'pyroscope.server.alloc_objects_2022-03-09_2025-to-2022-03-09_2025'
    51        );
    52      });
    53  
    54      it('uses the appname if its the only thing available', () => {
    55        expect(getFilename('pyroscope.server.alloc_objects')).toBe(
    56          'pyroscope.server.alloc_objects'
    57        );
    58      });
    59  
    60      it('uses the the date if its the only thing available', () => {
    61        expect(
    62          getFilename(
    63            undefined,
    64            TestData.metadata.startTime,
    65            TestData.metadata.endTime
    66          )
    67        ).toBe('flamegraph_2022-03-09_2025-to-2022-03-09_2025');
    68      });
    69  
    70      it('uses a generic name if nothing is available ', () => {
    71        expect(getFilename()).toBe('flamegraph');
    72      });
    73    });
    74  });
    75  
    76  // const TestData = {
    77  //  version: 1,
    78  //  flamebearer: {
    79  //    names: [
    80  //      'total',
    81  //      'runtime/pprof.profileWriter',
    82  //      'runtime/pprof.newProfileBuilder',
    83  //      'runtime/pprof.(*profileBuilder).readMapping',
    84  //      'runtime/pprof.parseProcSelfMaps',
    85  //      'os.ReadFile',
    86  //      'runtime/pprof.(*profileBuilder).build',
    87  //      'runtime/pprof.(*protobuf).varint',
    88  //      'runtime/pprof.(*protobuf).string',
    89  //      'runtime/pprof.(*profileBuilder).appendLocsForStack',
    90  //      'runtime/pprof.allFrames',
    91  //      'runtime/pprof.(*profileBuilder).stringIndex',
    92  //      'runtime/pprof.(*profileBuilder).emitLocation',
    93  //      'runtime/pprof.(*profileBuilder).pbLine',
    94  //      'runtime/pprof.(*profileBuilder).flush',
    95  //      'compress/gzip.(*Writer).Write',
    96  //      'compress/flate.NewWriter',
    97  //      'compress/flate.(*compressor).init',
    98  //      'runtime/pprof.(*pcDeck).tryAdd',
    99  //      'compress/flate.newDeflateFast',
   100  //      'compress/flate.(*Writer).Close',
   101  //      'compress/flate.(*compressor).close',
   102  //      'compress/flate.(*compressor).encSpeed',
   103  //      'compress/flate.(*huffmanBitWriter).writeBlockDynamic',
   104  //      'compress/flate.(*huffmanBitWriter).indexTokens',
   105  //      'compress/flate.(*huffmanEncoder).generate',
   106  //      'runtime/pprof.(*profileBuilder).addCPUData',
   107  //      'runtime/pprof.(*profMap).lookup',
   108  //      'net/http.HandlerFunc.ServeHTTP',
   109  //      'github.com/slok/go-http-metrics/middleware/std.Handler.func1',
   110  //      'github.com/slok/go-http-metrics/middleware.Middleware.Measure',
   111  //      'github.com/slok/go-http-metrics/middleware/std.Handler.func1.1',
   112  //      'github.com/pyroscope-io/pyroscope/pkg/storage.(*Storage).Get',
   113  //      'github.com/pyroscope-io/pyroscope/pkg/storage.(*Storage).GetContext',
   114  //      'github.com/pyroscope-io/pyroscope/pkg/storage/segment.(*Segment).GetContext',
   115  //      'github.com/pyroscope-io/pyroscope/pkg/storage/segment.(*streeNode).get',
   116  //      'github.com/pyroscope-io/pyroscope/pkg/storage/segment.(*Segment).GetContext.func1',
   117  //      'github.com/pyroscope-io/pyroscope/pkg/storage.(*Storage).GetContext.func1',
   118  //      'github.com/pyroscope-io/pyroscope/pkg/storage/cache.(*Cache).Lookup',
   119  //      'github.com/pyroscope-io/pyroscope/pkg/storage/cache.(*Cache).get',
   120  //      'github.com/pyroscope-io/pyroscope/pkg/storage/cache/lfu.(*Cache).GetOrSet',
   121  //      'github.com/pyroscope-io/pyroscope/pkg/storage/cache.(*Cache).get.func1',
   122  //      'github.com/pyroscope-io/pyroscope/pkg/storage.treeCodec.Deserialize',
   123  //      'github.com/pyroscope-io/pyroscope/pkg/storage/tree.Deserialize',
   124  //      'github.com/pyroscope-io/pyroscope/pkg/storage/dict.(*Dict).GetValue',
   125  //      'bytes.NewReader',
   126  //      'github.com/pyroscope-io/pyroscope/pkg/storage/cache.(*Cache).GetOrCreate',
   127  //      'github.com/pyroscope-io/pyroscope/pkg/storage/cache/lfu.(*Cache).increment',
   128  //      'net/http.(*conn).serve',
   129  //      'net/http.serverHandler.ServeHTTP',
   130  //      'github.com/klauspost/compress/gzhttp.NewWrapper.func1.1',
   131  //      'github.com/klauspost/compress/gzhttp.NewWrapper.func1.1.1',
   132  //      'github.com/klauspost/compress/gzhttp.(*GzipResponseWriter).Close',
   133  //      'github.com/klauspost/compress/gzhttp/writer/gzkp.(*pooledWriter).Close',
   134  //      'github.com/klauspost/compress/flate.(*Writer).Close',
   135  //      'github.com/klauspost/compress/flate.(*compressor).close',
   136  //      'github.com/klauspost/compress/flate.(*compressor).storeFast',
   137  //      'github.com/klauspost/compress/flate.(*fastGen).addBlock',
   138  //      'github.com/gorilla/mux.(*Router).ServeHTTP',
   139  //      'github.com/pyroscope-io/pyroscope/pkg/storage/tree.(*Tree).Merge',
   140  //      'github.com/pyroscope-io/pyroscope/pkg/server.(*Controller).renderHandler',
   141  //      'github.com/pyroscope-io/pyroscope/pkg/structs/flamebearer.NewProfile',
   142  //      'github.com/pyroscope-io/pyroscope/pkg/storage/tree.(*Tree).FlamebearerStruct',
   143  //      'github.com/pyroscope-io/pyroscope/pkg/server.(*Controller).writeResponseJSON',
   144  //      'encoding/json.(*Encoder).Encode',
   145  //      'github.com/slok/go-http-metrics/middleware/std.(*responseWriterInterceptor).Write',
   146  //      'github.com/klauspost/compress/gzhttp.(*GzipResponseWriter).Write',
   147  //      'github.com/klauspost/compress/gzhttp.(*GzipResponseWriter).startGzip',
   148  //      'github.com/klauspost/compress/gzip.(*Writer).Write',
   149  //      'github.com/klauspost/compress/flate.NewWriter',
   150  //      'github.com/klauspost/compress/flate.newFastEnc',
   151  //      'net/http.(*fileHandler).ServeHTTP',
   152  //      'net/http.serveFile',
   153  //      'net/http.serveContent',
   154  //      'io.Copy',
   155  //      'io.copyBuffer',
   156  //      'github.com/klauspost/compress/flate.(*Writer).Write',
   157  //      'github.com/klauspost/compress/flate.(*compressor).write',
   158  //      'github.com/pyroscope-io/pyroscope/pkg/storage/tree.(*treeNode).clone',
   159  //      'github.com/pyroscope-io/pyroscope/pkg/storage/segment.(*Segment).Put',
   160  //      'github.com/pyroscope-io/pyroscope/pkg/storage/segment.(*streeNode).put',
   161  //      'github.com/pyroscope-io/pyroscope/pkg/storage/segment.(*Segment).Put.func1',
   162  //      'github.com/pyroscope-io/pyroscope/pkg/storage.(*Storage).Put.func1',
   163  //      'github.com/pyroscope-io/pyroscope/pkg/storage/tree.(*Tree).Clone',
   164  //      'github.com/pyroscope-io/pyroscope/pkg/storage/cache.New.func2',
   165  //      'github.com/pyroscope-io/pyroscope/pkg/storage/cache.(*Cache).saveToDisk',
   166  //      'github.com/pyroscope-io/pyroscope/pkg/storage.treeCodec.Serialize',
   167  //      'github.com/pyroscope-io/pyroscope/pkg/storage/tree.(*Tree).SerializeTruncate',
   168  //      'github.com/valyala/bytebufferpool.(*ByteBuffer).Write',
   169  //      'github.com/pyroscope-io/pyroscope/pkg/structs/cappedarr.New',
   170  //      'github.com/pyroscope-io/pyroscope/pkg/storage/tree.(*Tree).minValue',
   171  //      'github.com/pyroscope-io/pyroscope/pkg/storage/tree.(*Tree).iterateWithTotal',
   172  //      'github.com/pyroscope-io/pyroscope/pkg/storage/dict.(*Dict).Put',
   173  //      'github.com/pyroscope-io/pyroscope/pkg/util/varint.NewWriter',
   174  //      'github.com/pyroscope-io/pyroscope/pkg/storage/dict.(*trieNode).findNodeAt',
   175  //      'github.com/pyroscope-io/pyroscope/pkg/util/varint.Writer.Write',
   176  //      'bytes.(*Buffer).Write',
   177  //      'bytes.(*Buffer).grow',
   178  //      'github.com/pyroscope-io/pyroscope/pkg/storage.segmentCodec.Serialize',
   179  //      'github.com/pyroscope-io/pyroscope/pkg/storage/segment.(*Segment).Serialize',
   180  //      'github.com/pyroscope-io/pyroscope/pkg/storage/segment.(*Segment).serialize',
   181  //      'github.com/pyroscope-io/pyroscope/pkg/storage.dictionaryCodec.Serialize',
   182  //      'github.com/pyroscope-io/pyroscope/pkg/storage/dict.(*Dict).Serialize',
   183  //      'github.com/pyroscope-io/pyroscope/pkg/agent/upstream/direct.(*Direct).uploadLoop',
   184  //      'github.com/pyroscope-io/pyroscope/pkg/agent/upstream/direct.(*Direct).safeUpload',
   185  //      'github.com/pyroscope-io/pyroscope/pkg/agent/upstream/direct.(*Direct).uploadProfile',
   186  //      'github.com/sirupsen/logrus.(*Entry).Debug',
   187  //      'github.com/sirupsen/logrus.(*Entry).Log',
   188  //      'github.com/sirupsen/logrus.Entry.log',
   189  //      'github.com/sirupsen/logrus.(*Entry).write',
   190  //      'github.com/sirupsen/logrus.(*TextFormatter).Format',
   191  //      'github.com/pyroscope-io/pyroscope/pkg/structs/transporttrie.(*Trie).Iterate',
   192  //      'github.com/pyroscope-io/pyroscope/pkg/storage/tree.(*Tree).Insert',
   193  //      'github.com/pyroscope-io/pyroscope/pkg/storage/segment.ParseKey',
   194  //      'github.com/pyroscope-io/pyroscope/pkg/storage/segment.(*parser).nameParserCase',
   195  //      'github.com/pyroscope-io/pyroscope/pkg/storage.(*Storage).Put',
   196  //      'github.com/sirupsen/logrus.(*Logger).WithFields',
   197  //      'github.com/sirupsen/logrus.(*Logger).newEntry',
   198  //      'sync.(*Pool).Get',
   199  //      'sync.(*Pool).pin',
   200  //      'sync.(*Pool).pinSlow',
   201  //      'github.com/sirupsen/logrus.(*Entry).WithFields',
   202  //      'github.com/pyroscope-io/pyroscope/pkg/storage/tree.newNode',
   203  //      'github.com/pyroscope-io/pyroscope/pkg/storage/segment.(*Key).TreeKey',
   204  //      'github.com/pyroscope-io/pyroscope/pkg/structs/sortedmap.New',
   205  //      'github.com/pyroscope-io/pyroscope/pkg/storage/labels.(*Labels).Put',
   206  //      'github.com/dgraph-io/badger/v2.(*DB).Update',
   207  //      'github.com/dgraph-io/badger/v2.(*Txn).Commit',
   208  //      'github.com/dgraph-io/badger/v2.(*Txn).commitAndSend',
   209  //      'github.com/pyroscope-io/pyroscope/pkg/agent.(*ProfileSession).takeSnapshots',
   210  //      'github.com/pyroscope-io/pyroscope/pkg/agent/gospy.(*GoSpy).Snapshot',
   211  //      'runtime/pprof.writeHeap',
   212  //      'runtime/pprof.writeHeapInternal',
   213  //      'runtime/pprof.writeHeapProto',
   214  //      'runtime/pprof.(*profileBuilder).pbSample',
   215  //      'github.com/valyala/bytebufferpool.(*ByteBuffer).WriteString',
   216  //      'github.com/pyroscope-io/pyroscope/pkg/storage/tree.(*Profile).Get',
   217  //      'github.com/pyroscope-io/pyroscope/pkg/agent/gospy.(*GoSpy).Snapshot.func3',
   218  //      'github.com/pyroscope-io/pyroscope/pkg/agent.(*ProfileSession).takeSnapshots.func1',
   219  //      'github.com/pyroscope-io/pyroscope/pkg/structs/transporttrie.(*Trie).Insert',
   220  //      'github.com/pyroscope-io/pyroscope/pkg/structs/transporttrie.newTrieNode',
   221  //      'github.com/pyroscope-io/pyroscope/pkg/structs/transporttrie.(*trieNode).findNodeAt',
   222  //      'github.com/pyroscope-io/pyroscope/pkg/structs/transporttrie.(*trieNode).insert',
   223  //      'github.com/pyroscope-io/pyroscope/pkg/agent.mergeTagsWithAppName',
   224  //      'github.com/pyroscope-io/pyroscope/pkg/convert.ParsePprof',
   225  //      'io.ReadAll',
   226  //      'google.golang.org/protobuf/proto.Unmarshal',
   227  //      'google.golang.org/protobuf/proto.UnmarshalOptions.unmarshal',
   228  //      'google.golang.org/protobuf/internal/impl.(*MessageInfo).unmarshal',
   229  //      'google.golang.org/protobuf/internal/impl.(*MessageInfo).unmarshalPointer',
   230  //      'google.golang.org/protobuf/internal/impl.consumeMessageSliceInfo',
   231  //      'reflect.New',
   232  //      'github.com/pyroscope-io/pyroscope/pkg/agent/gospy.getHeapProfile',
   233  //      'google.golang.org/protobuf/internal/impl.pointer.AppendPointerSlice',
   234  //      'google.golang.org/protobuf/internal/impl.consumeStringSliceValidateUTF8',
   235  //      'google.golang.org/protobuf/internal/impl.consumeUint64Slice',
   236  //      'google.golang.org/protobuf/internal/impl.consumeInt64Slice',
   237  //      'compress/gzip.NewReader',
   238  //      'compress/gzip.(*Reader).Reset',
   239  //      'compress/gzip.(*Reader).readHeader',
   240  //      'compress/flate.(*dictDecoder).init',
   241  //      'github.com/pyroscope-io/pyroscope/pkg/agent/gospy.(*GoSpy).Snapshot.func1',
   242  //      'github.com/pyroscope-io/pyroscope/pkg/agent/gospy.startCPUProfile',
   243  //      'runtime/pprof.StartCPUProfile',
   244  //      'github.com/pyroscope-io/pyroscope/pkg/agent.(*ProfileSession).reset',
   245  //      'github.com/pyroscope-io/pyroscope/pkg/agent.(*ProfileSession).uploadTries',
   246  //      'github.com/pyroscope-io/pyroscope/pkg/structs/transporttrie.(*Trie).Diff',
   247  //      'github.com/pyroscope-io/pyroscope/pkg/structs/transporttrie.(*Trie).Diff.func1',
   248  //      'github.com/pyroscope-io/pyroscope/pkg/structs/transporttrie.(*trieNode).clone',
   249  //      'github.com/dgraph-io/badger/v2.(*DB).updateSize',
   250  //      'github.com/dgraph-io/badger/v2.(*DB).calculateSize',
   251  //      'github.com/dgraph-io/badger/v2.(*DB).calculateSize.func2',
   252  //      'path/filepath.Walk',
   253  //      'path/filepath.walk',
   254  //      'path/filepath.readDirNames',
   255  //      'os.(*File).Readdirnames',
   256  //      'os.(*File).readdir',
   257  //      'github.com/dgraph-io/badger/v2.(*DB).doWrites.func1',
   258  //      'github.com/dgraph-io/badger/v2.(*DB).writeRequests',
   259  //      'github.com/dgraph-io/badger/v2.(*valueLog).write',
   260  //      'github.com/dgraph-io/badger/v2.(*logFile).encodeEntry',
   261  //      'bytes.makeSlice',
   262  //    ],
   263  //    levels: [
   264  //      [0, 4147083, 0, 0],
   265  //      [
   266  //        0, 344, 0, 177, 0, 64, 0, 169, 0, 8193, 0, 58, 0, 2315453, 415074, 129,
   267  //        0, 839135, 0, 103, 0, 861368, 0, 84, 0, 8193, 0, 79, 0, 8193, 0, 78, 0,
   268  //        15438, 0, 48, 0, 17477, 0, 28, 0, 73225, 0, 1,
   269  //      ],
   270  //      [
   271  //        0, 344, 0, 178, 0, 64, 0, 170, 0, 8193, 0, 28, 415074, 345011, 0, 164,
   272  //        0, 1555368, 0, 130, 0, 839135, 0, 104, 0, 861368, 0, 85, 0, 8193, 0, 80,
   273  //        0, 8193, 0, 78, 0, 15438, 0, 49, 0, 17477, 0, 28, 0, 65, 0, 26, 0, 7441,
   274  //        0, 6, 0, 65719, 0, 2,
   275  //      ],
   276  //      [
   277  //        0, 344, 0, 179, 0, 64, 0, 171, 0, 8193, 0, 28, 415074, 345011, 0, 165,
   278  //        0, 778, 745, 157, 0, 46, 0, 161, 0, 686849, 0, 152, 0, 10222, 0, 144, 0,
   279  //        578792, 0, 136, 0, 2731, 2731, 135, 0, 275950, 0, 131, 0, 839135, 4097,
   280  //        105, 0, 26494, 0, 101, 0, 47, 0, 98, 0, 834827, 0, 86, 0, 8193, 0, 81,
   281  //        0, 8193, 0, 78, 0, 15438, 0, 28, 0, 17477, 0, 29, 0, 65, 65, 27, 0, 228,
   282  //        0, 20, 0, 134, 0, 15, 0, 6809, 0, 9, 0, 98, 98, 8, 0, 172, 172, 7, 0,
   283  //        65719, 0, 3,
   284  //      ],
   285  //      [
   286  //        0, 344, 0, 180, 0, 64, 0, 172, 0, 8193, 0, 29, 415074, 345011, 88237,
   287  //        166, 745, 33, 0, 158, 0, 46, 0, 162, 0, 33, 0, 157, 0, 686816, 0, 144,
   288  //        0, 10144, 0, 146, 0, 78, 78, 145, 0, 578792, 0, 137, 2731, 275950, 30,
   289  //        132, 4097, 278195, 0, 115, 0, 32768, 0, 113, 0, 518613, 507690, 111, 0,
   290  //        5462, 0, 106, 0, 26494, 26494, 102, 0, 47, 0, 99, 0, 834827, 105818, 87,
   291  //        0, 8193, 0, 82, 0, 8193, 0, 78, 0, 15438, 0, 50, 0, 17477, 0, 30, 65,
   292  //        228, 0, 21, 0, 134, 29, 16, 0, 3277, 3277, 18, 0, 591, 293, 12, 0, 192,
   293  //        192, 11, 0, 228, 228, 7, 0, 2521, 2521, 10, 270, 182, 182, 5, 0, 65537,
   294  //        65537, 4,
   295  //      ],
   296  //      [
   297  //        0, 344, 0, 96, 0, 64, 0, 173, 0, 8193, 0, 30, 503311, 90117, 0, 168, 0,
   298  //        166657, 0, 141, 745, 33, 0, 159, 0, 46, 46, 163, 0, 33, 0, 158, 0,
   299  //        686346, 0, 146, 0, 470, 470, 145, 0, 10144, 0, 147, 78, 578792, 0, 138,
   300  //        2761, 275920, 24578, 133, 4097, 5462, 0, 125, 0, 255050, 0, 79, 0,
   301  //        17683, 0, 116, 0, 32768, 32768, 114, 507690, 10923, 10923, 112, 0, 5462,
   302  //        0, 107, 26494, 47, 0, 100, 105818, 593133, 396514, 92, 0, 135623, 0, 90,
   303  //        0, 227, 227, 89, 0, 26, 26, 88, 0, 8193, 0, 83, 0, 8193, 0, 78, 0,
   304  //        15436, 0, 58, 0, 2, 0, 51, 0, 17477, 0, 31, 65, 228, 0, 22, 29, 58, 58,
   305  //        17, 0, 47, 47, 19, 3570, 5, 0, 14, 0, 293, 0, 13,
   306  //      ],
   307  //      [
   308  //        0, 344, 0, 97, 0, 64, 0, 174, 0, 8193, 0, 31, 503311, 90117, 0, 168, 0,
   309  //        166657, 166657, 167, 745, 33, 33, 160, 46, 33, 0, 159, 0, 686346, 0,
   310  //        147, 470, 10144, 0, 148, 78, 23667, 0, 143, 0, 555125, 284775, 139,
   311  //        27339, 250440, 0, 9, 0, 271, 0, 6, 0, 43, 0, 134, 0, 588, 0, 2, 4097,
   312  //        5462, 0, 126, 0, 255050, 0, 80, 0, 17426, 17426, 121, 0, 257, 0, 117,
   313  //        551381, 5462, 0, 108, 26494, 47, 0, 100, 502332, 163850, 0, 94, 0,
   314  //        32769, 32769, 93, 0, 135623, 135623, 91, 253, 8193, 0, 78, 0, 8193, 0,
   315  //        78, 0, 5, 0, 71, 0, 15431, 0, 28, 0, 2, 0, 52, 0, 17477, 0, 28, 65, 228,
   316  //        0, 23, 3704, 5, 0, 15, 0, 293, 293, 7,
   317  //      ],
   318  //      [
   319  //        0, 344, 344, 181, 0, 64, 0, 175, 0, 8193, 0, 28, 503311, 90117, 0, 168,
   320  //        167481, 33, 33, 160, 0, 686346, 0, 148, 470, 10144, 0, 149, 78, 1821, 0,
   321  //        113, 0, 21846, 21846, 124, 284775, 122885, 0, 141, 0, 147465, 147465,
   322  //        140, 27339, 820, 201, 12, 0, 147, 147, 11, 0, 410, 410, 7, 0, 249063,
   323  //        249063, 10, 0, 29, 29, 11, 0, 233, 233, 8, 0, 9, 9, 7, 0, 43, 0, 14, 0,
   324  //        588, 0, 3, 4097, 5462, 0, 127, 0, 255050, 0, 81, 17426, 257, 0, 118,
   325  //        551381, 5462, 0, 109, 26494, 47, 0, 100, 502332, 163850, 0, 95, 168645,
   326  //        8193, 0, 78, 0, 8193, 0, 78, 0, 5, 0, 72, 0, 15431, 0, 28, 0, 2, 0, 53,
   327  //        0, 17477, 0, 28, 65, 228, 0, 24, 3704, 5, 3, 16,
   328  //      ],
   329  //      [
   330  //        344, 64, 64, 176, 0, 8193, 0, 28, 503311, 90117, 0, 168, 167514, 686346,
   331  //        0, 149, 470, 10144, 0, 150, 78, 1821, 1821, 114, 306621, 122885, 122885,
   332  //        142, 175005, 107, 0, 14, 0, 512, 512, 7, 249891, 43, 0, 15, 0, 588, 588,
   333  //        5, 4097, 5462, 5462, 128, 0, 255050, 0, 82, 17426, 257, 0, 119, 551381,
   334  //        5462, 5462, 110, 26494, 47, 0, 100, 502332, 163850, 0, 96, 168645, 8193,
   335  //        0, 78, 0, 8193, 0, 78, 0, 5, 0, 73, 0, 15431, 0, 29, 0, 2, 0, 54, 0,
   336  //        17477, 0, 28, 65, 228, 228, 25, 3707, 2, 2, 17,
   337  //      ],
   338  //      [
   339  //        408, 8193, 0, 28, 503311, 90117, 0, 168, 167514, 658478, 0, 150, 0,
   340  //        27309, 27309, 154, 0, 559, 559, 153, 470, 10144, 10144, 151, 606410,
   341  //        107, 0, 15, 250403, 43, 3, 16, 10147, 10923, 0, 123, 0, 196611, 0, 83,
   342  //        0, 47516, 39323, 59, 17426, 257, 257, 120, 583337, 47, 0, 100, 502332,
   343  //        163850, 163850, 97, 168645, 8193, 0, 78, 0, 8193, 0, 78, 0, 5, 0, 74, 0,
   344  //        15431, 0, 30, 0, 2, 0, 55, 0, 17477, 0, 32,
   345  //      ],
   346  //      [
   347  //        408, 8193, 0, 32, 503311, 90117, 0, 168, 167514, 510384, 0, 149, 0,
   348  //        148094, 148094, 151, 644892, 107, 25, 16, 250406, 14, 14, 17, 0, 26, 26,
   349  //        19, 10147, 10923, 10923, 124, 0, 196611, 0, 78, 39323, 8193, 8193, 122,
   350  //        601020, 47, 0, 100, 834827, 8193, 0, 78, 0, 8193, 0, 78, 0, 5, 0, 75, 0,
   351  //        15431, 0, 31, 0, 2, 0, 56, 0, 17477, 0, 33,
   352  //      ],
   353  //      [
   354  //        408, 8193, 0, 33, 503311, 90117, 0, 168, 167514, 163843, 163843, 156, 0,
   355  //        96672, 0, 150, 0, 184332, 184332, 155, 0, 65537, 65537, 153, 793011, 40,
   356  //        40, 17, 0, 42, 42, 19, 271516, 196611, 0, 78, 648536, 15, 0, 100, 0, 32,
   357  //        0, 95, 834827, 8193, 0, 78, 0, 8193, 0, 78, 0, 5, 0, 66, 0, 15431, 0,
   358  //        28, 0, 2, 2, 57, 0, 17477, 0, 34,
   359  //      ],
   360  //      [
   361  //        408, 8193, 0, 34, 503311, 90117, 0, 168, 331357, 96672, 96672, 151,
   362  //        1314478, 196611, 16385, 78, 648536, 15, 0, 95, 0, 32, 32, 88, 834827,
   363  //        8193, 0, 78, 0, 8193, 0, 78, 0, 2, 0, 76, 0, 3, 0, 67, 0, 15431, 0, 28,
   364  //        2, 17477, 0, 35,
   365  //      ],
   366  //      [
   367  //        408, 8193, 0, 35, 503311, 90117, 0, 168, 1758892, 180226, 65537, 78,
   368  //        648536, 15, 15, 88, 834859, 8193, 0, 78, 0, 8193, 0, 78, 0, 2, 0, 77, 0,
   369  //        3, 0, 68, 0, 15431, 0, 28, 2, 17477, 0, 35,
   370  //      ],
   371  //      [
   372  //        408, 8193, 0, 35, 503311, 90117, 0, 168, 1824429, 114689, 8192, 78,
   373  //        1483410, 8193, 0, 78, 0, 8193, 0, 78, 0, 2, 0, 56, 0, 3, 3, 69, 0, 2323,
   374  //        0, 60, 0, 13108, 0, 32, 2, 17477, 0, 35,
   375  //      ],
   376  //      [
   377  //        408, 8193, 0, 35, 503311, 90117, 0, 168, 1832621, 106497, 0, 78,
   378  //        1483410, 8193, 0, 78, 0, 8193, 0, 78, 0, 2, 2, 57, 3, 10, 0, 63, 0,
   379  //        2313, 0, 61, 0, 13108, 0, 33, 2, 17477, 0, 35,
   380  //      ],
   381  //      [
   382  //        408, 8193, 0, 35, 503311, 90117, 16385, 168, 1832621, 106497, 73728, 78,
   383  //        1483410, 8193, 0, 78, 0, 8193, 0, 78, 5, 10, 0, 64, 0, 2313, 2313, 62,
   384  //        0, 13108, 0, 34, 2, 17477, 0, 35,
   385  //      ],
   386  //      [
   387  //        408, 8193, 0, 35, 519696, 73732, 0, 168, 1906349, 32769, 0, 78, 1483410,
   388  //        8193, 0, 78, 0, 8193, 0, 78, 5, 10, 0, 65, 2313, 13108, 0, 35, 2, 17477,
   389  //        0, 35,
   390  //      ],
   391  //      [
   392  //        408, 8193, 0, 35, 519696, 73732, 16385, 168, 1906349, 32769, 0, 78,
   393  //        1483410, 8193, 0, 78, 0, 8193, 0, 78, 5, 10, 0, 66, 2313, 13108, 0, 35,
   394  //        2, 6554, 0, 36, 0, 10923, 0, 35,
   395  //      ],
   396  //      [
   397  //        408, 8193, 0, 35, 536081, 57347, 8192, 168, 1906349, 32769, 24577, 78,
   398  //        1483410, 8193, 0, 78, 0, 8193, 0, 78, 5, 10, 0, 67, 2313, 13108, 0, 35,
   399  //        2, 6554, 0, 37, 0, 10923, 0, 36,
   400  //      ],
   401  //      [
   402  //        408, 8193, 0, 36, 544273, 49155, 8193, 168, 1930926, 8192, 8192, 78,
   403  //        1483410, 8193, 0, 78, 0, 8193, 0, 78, 5, 10, 0, 68, 2313, 13108, 0, 35,
   404  //        2, 6554, 0, 38, 0, 10923, 0, 37,
   405  //      ],
   406  //      [
   407  //        408, 8193, 0, 37, 552466, 40962, 0, 168, 3422528, 8193, 0, 78, 0, 8193,
   408  //        0, 78, 5, 10, 5, 69, 2313, 13108, 0, 35, 2, 6554, 0, 39, 0, 10923, 0,
   409  //        38,
   410  //      ],
   411  //      [
   412  //        408, 8193, 0, 38, 552466, 40962, 8192, 168, 3422528, 8193, 0, 78, 0,
   413  //        8193, 0, 78, 10, 5, 5, 70, 2313, 13108, 0, 35, 2, 6554, 0, 40, 0, 10923,
   414  //        0, 39,
   415  //      ],
   416  //      [
   417  //        408, 8193, 0, 39, 560658, 32770, 8192, 168, 3422528, 8193, 0, 78, 0,
   418  //        8193, 0, 78, 2328, 6554, 0, 36, 0, 6554, 0, 35, 2, 6554, 0, 41, 0,
   419  //        10923, 0, 40,
   420  //      ],
   421  //      [
   422  //        408, 8193, 0, 40, 568850, 24578, 0, 168, 3422528, 8193, 0, 78, 0, 8193,
   423  //        0, 78, 2328, 6554, 0, 37, 0, 6554, 0, 36, 2, 6554, 0, 42, 0, 10923, 0,
   424  //        41,
   425  //      ],
   426  //      [
   427  //        408, 8193, 0, 41, 568850, 24578, 8193, 168, 3422528, 8193, 0, 78, 0,
   428  //        8193, 0, 78, 2328, 6554, 6554, 59, 0, 6554, 0, 37, 2, 6554, 0, 46, 0,
   429  //        10923, 0, 42,
   430  //      ],
   431  //      [
   432  //        408, 8193, 0, 42, 577043, 16385, 8193, 168, 3422528, 8193, 0, 78, 0,
   433  //        8193, 0, 78, 8882, 6554, 6554, 59, 2, 6554, 0, 39, 0, 10923, 0, 43,
   434  //      ],
   435  //      [
   436  //        408, 8193, 0, 43, 585236, 8192, 0, 168, 3422528, 8193, 0, 78, 0, 8193,
   437  //        0, 78, 15438, 6554, 0, 40, 0, 10923, 0, 44,
   438  //      ],
   439  //      [
   440  //        408, 8193, 8193, 122, 585236, 8192, 8192, 168, 3422528, 8193, 0, 78, 0,
   441  //        8193, 0, 78, 15438, 6554, 6554, 47, 0, 10923, 10923, 45,
   442  //      ],
   443  //      [4024557, 8193, 0, 78, 0, 8193, 0, 78],
   444  //      [4024557, 8193, 0, 78, 0, 8193, 0, 78],
   445  //      [4024557, 8193, 0, 78, 0, 8193, 0, 78],
   446  //      [4024557, 8193, 8193, 78, 0, 8193, 8193, 78],
   447  //    ],
   448  //    numTicks: 4147083,
   449  //    maxSelf: 507690,
   450  //  },
   451  //  timeline: {
   452  //    startTime: 1642688200,
   453  //    samples: [
   454  //      52997, 314116, 166037, 145716, 119938, 156626, 95277, 299103, 42874,
   455  //      103485, 78324, 50019, 93481, 257538, 246101, 75713, 127838, 89530, 112918,
   456  //      268927, 79218, 61979, 117654, 87601, 88796, 316884, 103538, 131815,
   457  //      113310, 149760, 0,
   458  //    ],
   459  //    durationDelta: 10,
   460  //    watermarks: {},
   461  //  },
   462  //  metadata: {
   463  //    format: 'single',
   464  //    spyName: 'gospy',
   465  //    sampleRate: 100,
   466  //    units: 'objects',
   467  //    appName: 'pyroscope.server.alloc_objects',
   468  //    startTime: 1642688208,
   469  //    endTime: 1642688508,
   470  //    query: 'pyroscope.server.alloc_objects{}',
   471  //    maxNodes: 1024,
   472  //  },
   473  // };
   474  
   475  const TestData: Profile = {
   476    version: 1,
   477    flamebearer: {
   478      names: [
   479        'total',
   480        'runtime.main',
   481        'main.main',
   482        'github.com/pyroscope-io/client/pyroscope.TagWrapper',
   483        'runtime/pprof.Do',
   484        'github.com/pyroscope-io/client/pyroscope.TagWrapper.func1',
   485        'main.main.func1',
   486        'main.slowFunction',
   487        'main.slowFunction.func1',
   488        'main.work',
   489        'main.fastFunction',
   490        'main.fastFunction.func1',
   491      ],
   492      levels: [
   493        [0, 95, 0, 0],
   494        [0, 95, 0, 1],
   495        [0, 95, 0, 2],
   496        [0, 95, 0, 3],
   497        [0, 95, 0, 4],
   498        [0, 95, 0, 5],
   499        [0, 95, 0, 6],
   500        [0, 19, 0, 10, 0, 76, 0, 7],
   501        [0, 19, 0, 3, 0, 76, 0, 4],
   502        [0, 19, 0, 4, 0, 76, 0, 8],
   503        [0, 19, 0, 5, 0, 76, 76, 9],
   504        [0, 19, 0, 11],
   505        [0, 19, 19, 9],
   506      ],
   507      numTicks: 95,
   508      maxSelf: 76,
   509    },
   510    metadata: {
   511      format: 'single',
   512      spyName: 'gospy',
   513      sampleRate: 100,
   514      units: 'samples',
   515      name: 'simple.golang.app.cpu 2022-03-09T20:25:55Z',
   516      appName: 'simple.golang.app.cpu',
   517      startTime: 1646857555,
   518      endTime: 1646857555,
   519      query: 'simple.golang.app.cpu{}',
   520      maxNodes: 8192,
   521    },
   522  };