rails_mini_profiler 0.7.1 → 0.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '08b93a903a5bb3b16310b3a918a1a52555a9ce5fc2a60624d0f2bb8158e3ddb5'
4
- data.tar.gz: 88af5220a54c4f91e4506cd0423a853512dcc67235c65a22990d1c4fc1d92c25
3
+ metadata.gz: cd5f0289e557632fc0784507d570dfded6fec70d39fc32f074b3533cb4042874
4
+ data.tar.gz: 606d14a92ca9f2e6b09112d54f23f2da552fb9a667c41a05bd06b62a540a038d
5
5
  SHA512:
6
- metadata.gz: 2a41fec13f04188e895769fcb17004fdd6436aaddd8942ff4657beaffb7c0f4b63ca64d60f9877d119c1e363194ebd3c97e629216d0bf675fceb82cd49b6dcda
7
- data.tar.gz: f5c81dbc3b627e48a0d9097fb587b37c2c299476adb87d01ace6c697e234b32f8fceee942045656f82f8c4d6ef6c082e58ad2f5619ccf2b4114b32764dae8c8f
6
+ metadata.gz: 602438aa1e6bf65c2aad9293ab471998dbb0dd83518203f75e56b54e8a9809bb87b7be2c4594f0d1ca568f066d03d5eaae1608fbfa0539fda6748db0e1dff623
7
+ data.tar.gz: f7c27cba71c79b7b0cac2eb12e244c7670bd43ea2d0b92f1833541861af2700e303514b277daa19e11a6528c5bad2e5c8f7501fe7308d2600e980471caaf1867
@@ -5,7 +5,7 @@
5
5
  # Table name: rmp_flamegraphs
6
6
  #
7
7
  # id :integer not null, primary key
8
- # rmp_profiled_request_id :bigint not null
8
+ # rmp_profiled_request_id :integer not null
9
9
  # data :binary
10
10
  # created_at :datetime not null
11
11
  # updated_at :datetime not null
@@ -40,6 +40,8 @@ module RailsMiniProfiler
40
40
  foreign_key: :rmp_profiled_request_id,
41
41
  dependent: :destroy
42
42
 
43
+ before_save :sanitize
44
+
43
45
  def request=(request)
44
46
  self.request_body = request.body
45
47
  self.request_headers = request.headers
@@ -61,5 +63,14 @@ module RailsMiniProfiler
61
63
  self.duration = total_time.duration
62
64
  self.allocations = total_time.allocations
63
65
  end
66
+
67
+ private
68
+
69
+ def sanitize
70
+ self.request_body ||= ''
71
+ self.request_body = request_body
72
+ .encode('UTF-8', invalid: :replace, undef: :replace)
73
+ .delete("\000")
74
+ end
64
75
  end
65
76
  end
@@ -5,12 +5,12 @@
5
5
  # Table name: rmp_traces
6
6
  #
7
7
  # id :integer not null, primary key
8
- # rmp_profiled_request_id :bigint not null
8
+ # rmp_profiled_request_id :integer not null
9
9
  # name :string
10
- # start :bigint
11
- # finish :bigint
10
+ # start :integer
11
+ # finish :integer
12
12
  # duration :integer
13
- # allocations :bigint
13
+ # allocations :integer
14
14
  # payload :json
15
15
  # backtrace :json
16
16
  # created_at :datetime not null
@@ -2,7 +2,7 @@
2
2
 
3
3
  class CreateRmp < ActiveRecord::Migration[6.0]
4
4
  def change
5
- create_table :rmp_profiled_requests do |t|
5
+ create_table :rmp_profiled_requests, charset: 'utf8' do |t|
6
6
  t.string :user_id
7
7
  t.bigint :start
8
8
  t.bigint :finish
@@ -23,7 +23,7 @@ class CreateRmp < ActiveRecord::Migration[6.0]
23
23
  t.index :created_at
24
24
  end
25
25
 
26
- create_table :rmp_traces do |t|
26
+ create_table :rmp_traces, charset: 'utf8' do |t|
27
27
  t.belongs_to :rmp_profiled_request, null: false, foreign_key: true
28
28
  t.string :name
29
29
  t.bigint :start
@@ -36,7 +36,7 @@ class CreateRmp < ActiveRecord::Migration[6.0]
36
36
  t.timestamps
37
37
  end
38
38
 
39
- create_table :rmp_flamegraphs do |t|
39
+ create_table :rmp_flamegraphs, charset: 'utf8' do |t|
40
40
  t.belongs_to :rmp_profiled_request, null: false, foreign_key: true
41
41
  t.binary :data
42
42
 
@@ -3,6 +3,8 @@
3
3
  module RailsMiniProfiler
4
4
  module Tracers
5
5
  class Tracer
6
+ TIMESTAMP_MULTIPLIER = Rails::VERSION::MAJOR < 7 ? 100 : 1
7
+
6
8
  class << self
7
9
  def subscribes_to
8
10
  []
@@ -28,13 +30,18 @@ module RailsMiniProfiler
28
30
  private
29
31
 
30
32
  def event_data(event)
31
- start = (event.time.to_f * 100_000).to_i
32
- finish = (event.end.to_f * 100_000).to_i
33
+ # Rails 7 changes event timings and now uses CPU milliseconds as float for start and end. We multiply by 100
34
+ # to convert the float with precision of 2 digits to integer, because integers are just easier to store and
35
+ # process than floats.
36
+ #
37
+ # See https://github.com/rails/rails/commit/81d0dc90becfe0b8e7f7f26beb66c25d84b8ec7f
38
+ start = (event.time.to_f * TIMESTAMP_MULTIPLIER).to_i
39
+ finish = (event.end.to_f * TIMESTAMP_MULTIPLIER).to_i
33
40
  {
34
41
  name: event.name,
35
42
  start: start,
36
43
  finish: finish,
37
- duration: finish - start,
44
+ duration: (event.duration.to_f * 100).to_i,
38
45
  allocations: event.allocations,
39
46
  backtrace: Rails.backtrace_cleaner.clean(caller),
40
47
  payload: event.payload
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsMiniProfiler
4
- VERSION = '0.7.1'
4
+ VERSION = '0.7.3'
5
5
  end
@@ -1,9 +1,9 @@
1
1
  parcelRequire=function(e,r,t,n){var i,o="function"==typeof parcelRequire&&parcelRequire,u="function"==typeof require&&require;function f(t,n){if(!r[t]){if(!e[t]){var i="function"==typeof parcelRequire&&parcelRequire;if(!n&&i)return i(t,!0);if(o)return o(t,!0);if(u&&"string"==typeof t)return u(t);var c=new Error("Cannot find module '"+t+"'");throw c.code="MODULE_NOT_FOUND",c}p.resolve=function(r){return e[t][1][r]||r},p.cache={};var l=r[t]=new f.Module(t);e[t][0].call(l.exports,p,l,l.exports,this)}return r[t].exports;function p(e){return f(p.resolve(e))}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.exports={}},f.modules=e,f.cache=r,f.parent=o,f.register=function(r,t){e[r]=[function(e,r){r.exports=t},{}]};for(var c=0;c<t.length;c++)try{f(t[c])}catch(e){i||(i=e)}if(t.length){var l=f(t[t.length-1]);"object"==typeof exports&&"undefined"!=typeof module?module.exports=l:"function"==typeof define&&define.amd?define(function(){return l}):n&&(this[n]=l)}if(parcelRequire=f,i)throw i;return f}({"y1V0":[function(require,module,exports) {
2
2
  "use strict";function e(e){const t=[];return function e(r){t.push({id:r.id,callFrame:{columnNumber:0,functionName:r.functionName,lineNumber:r.lineNumber,scriptId:r.scriptId,url:r.url},hitCount:r.hitCount,children:r.children.map(e=>e.id)}),r.children.forEach(e)}(e),t}function t(e,t){return e.map((r,n)=>{return r-(0===n?1e6*t:e[n-1])})}function r(r){return{samples:r.samples,startTime:1e6*r.startTime,endTime:1e6*r.endTime,nodes:e(r.head),timeDeltas:t(r.timestamps,r.startTime)}}Object.defineProperty(exports,"__esModule",{value:!0}),exports.chromeTreeToNodes=r;
3
3
  },{}],"kWV1":[function(require,module,exports) {
4
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.isChromeTimeline=i,exports.importFromChromeTimeline=l,exports.importFromChromeCPUProfile=u,exports.importFromOldV8CPUProfile=f;var e=require("../lib/profile"),t=require("../lib/utils"),r=require("../lib/value-formatters"),n=require("./v8cpuFormatter");function i(e){if(!Array.isArray(e))return!1;if(e.length<1)return!1;const t=e[0];return"pid"in t&&"tid"in t&&"ph"in t&&"cat"in t&&!!e.find(e=>"CpuProfile"===e.name||"Profile"===e.name||"ProfileChunk"===e.name)}function l(e,r){const n=new Map,i=new Map,l=new Map;(0,t.sortBy)(e,e=>e.ts);for(let t of e){if("CpuProfile"===t.name){const e=`${t.pid}:${t.tid}`,r=t.id||e;n.set(r,t.args.data.cpuProfile),i.set(r,e)}if("Profile"===t.name){const e=`${t.pid}:${t.tid}`;n.set(t.id||e,Object.assign({startTime:0,endTime:0,nodes:[],samples:[],timeDeltas:[]},t.args.data)),t.id&&i.set(t.id,`${t.pid}:${t.tid}`)}if("thread_name"===t.name&&l.set(`${t.pid}:${t.tid}`,t.args.name),"ProfileChunk"===t.name){const e=`${t.pid}:${t.tid}`,r=n.get(t.id||e);if(r){const e=t.args.data;e.cpuProfile&&(e.cpuProfile.nodes&&(r.nodes=r.nodes.concat(e.cpuProfile.nodes)),e.cpuProfile.samples&&(r.samples=r.samples.concat(e.cpuProfile.samples))),e.timeDeltas&&(r.timeDeltas=r.timeDeltas.concat(e.timeDeltas)),null!=e.startTime&&(r.startTime=e.startTime),null!=e.endTime&&(r.endTime=e.endTime)}else console.warn(`Ignoring ProfileChunk for undeclared Profile with id ${t.id||e}`)}}if(n.size>0){const e=[];let o=0;return(0,t.itForEach)(n.keys(),t=>{let s=null,a=i.get(t);a&&(s=l.get(a)||null);const m=u(n.get(t));s&&n.size>1?(m.setName(`${r} - ${s}`),"CrRendererMain"===s&&(o=e.length)):m.setName(`${r}`),e.push(m)}),{name:r,indexToView:o,profiles:e}}throw new Error("Could not find CPU profile in Timeline")}const o=new Map;function s(e){return(0,t.getOrInsert)(o,e,e=>{const t=e.functionName||"(anonymous)",r=e.url;let n=e.lineNumber;null!=n&&n++;let i=e.columnNumber;return null!=i&&i++,{key:`${t}:${r}:${n}:${i}`,name:t,file:r,line:n,col:i}})}function a(e){const{functionName:t,url:r}=e;return"native dummy.js"===r||("(root)"===t||"(idle)"===t)}function m(e){return"(garbage collector)"===e||"(program)"===e}function u(n){const i=new e.CallTreeProfileBuilder(n.endTime-n.startTime),l=new Map;for(let e of n.nodes)l.set(e.id,e);for(let e of n.nodes)if("number"==typeof e.parent&&(e.parent=l.get(e.parent)),e.children)for(let t of e.children){const r=l.get(t);r&&(r.parent=e)}const o=[],u=[];let f=n.timeDeltas[0],c=f,p=NaN;for(let e=0;e<n.samples.length;e++){const t=n.samples[e];if(t!=p&&(o.push(t),f<c?u.push(c):(u.push(f),c=f)),e===n.samples.length-1)isNaN(p)||(o.push(p),f<c?u.push(c):(u.push(f),c=f));else{f+=n.timeDeltas[e+1],p=t}}let d=[];for(let e=0;e<o.length;e++){const r=u[e],n=o[e];let f=l.get(n);if(!f)continue;let c=null;for(c=f;c&&-1===d.indexOf(c);c=m(c.callFrame.functionName)?(0,t.lastOf)(d):c.parent||null);for(;d.length>0&&(0,t.lastOf)(d)!=c;){const e=s(d.pop().callFrame);i.leaveFrame(e,r)}const p=[];for(let e=f;e&&e!=c&&!a(e.callFrame);e=m(e.callFrame.functionName)?(0,t.lastOf)(d):e.parent||null)p.push(e);p.reverse();for(let e of p)i.enterFrame(s(e.callFrame),r);d=d.concat(p)}for(let e=d.length-1;e>=0;e--)i.leaveFrame(s(d[e].callFrame),(0,t.lastOf)(u));return i.setValueFormatter(new r.TimeFormatter("microseconds")),i.build()}function f(e){return u((0,n.chromeTreeToNodes)(e))}
4
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.isChromeTimeline=i,exports.importFromChromeTimeline=l,exports.importFromChromeCPUProfile=u,exports.importFromOldV8CPUProfile=f;var e=require("../lib/profile"),t=require("../lib/utils"),n=require("../lib/value-formatters"),r=require("./v8cpuFormatter");function i(e){if(!Array.isArray(e))return!1;if(e.length<1)return!1;const t=e[0];return"pid"in t&&"tid"in t&&"ph"in t&&"cat"in t&&!!e.find(e=>"CpuProfile"===e.name||"Profile"===e.name||"ProfileChunk"===e.name)}function l(e,n){const r=new Map,i=new Map,l=new Map;(0,t.sortBy)(e,e=>e.ts);for(let t of e){if("CpuProfile"===t.name){const e=`${t.pid}:${t.tid}`,n=t.id||e;r.set(n,t.args.data.cpuProfile),i.set(n,e)}if("Profile"===t.name){const e=`${t.pid}:${t.tid}`;r.set(t.id||e,Object.assign({startTime:0,endTime:0,nodes:[],samples:[],timeDeltas:[]},t.args.data)),t.id&&i.set(t.id,`${t.pid}:${t.tid}`)}if("thread_name"===t.name&&l.set(`${t.pid}:${t.tid}`,t.args.name),"ProfileChunk"===t.name){const e=`${t.pid}:${t.tid}`,n=r.get(t.id||e);if(n){const e=t.args.data;e.cpuProfile&&(e.cpuProfile.nodes&&(n.nodes=n.nodes.concat(e.cpuProfile.nodes)),e.cpuProfile.samples&&(n.samples=n.samples.concat(e.cpuProfile.samples))),e.timeDeltas&&(n.timeDeltas=n.timeDeltas.concat(e.timeDeltas)),null!=e.startTime&&(n.startTime=e.startTime),null!=e.endTime&&(n.endTime=e.endTime)}else console.warn(`Ignoring ProfileChunk for undeclared Profile with id ${t.id||e}`)}}if(r.size>0){const e=[];let o=0;return(0,t.itForEach)(r.keys(),t=>{let s=null,a=i.get(t);a&&(s=l.get(a)||null);const m=u(r.get(t));s&&r.size>1?(m.setName(`${n} - ${s}`),"CrRendererMain"===s&&(o=e.length)):m.setName(`${n}`),e.push(m)}),{name:n,indexToView:o,profiles:e}}throw new Error("Could not find CPU profile in Timeline")}const o=new Map;function s(e){return(0,t.getOrInsert)(o,e,e=>{const t=e.url;let n=e.lineNumber;null!=n&&n++;let r=e.columnNumber;null!=r&&r++;const i=e.functionName||(t?`(anonymous ${t.split("/").pop()}:${n})`:"(anonymous)");return{key:`${i}:${t}:${n}:${r}`,name:i,file:t,line:n,col:r}})}function a(e){const{functionName:t,url:n}=e;return"native dummy.js"===n||("(root)"===t||"(idle)"===t)}function m(e){return"(garbage collector)"===e||"(program)"===e}function u(r){const i=new e.CallTreeProfileBuilder(r.endTime-r.startTime),l=new Map;for(let e of r.nodes)l.set(e.id,e);for(let e of r.nodes)if("number"==typeof e.parent&&(e.parent=l.get(e.parent)),e.children)for(let t of e.children){const n=l.get(t);n&&(n.parent=e)}const o=[],u=[];let f=r.timeDeltas[0],c=f,p=NaN;for(let e=0;e<r.samples.length;e++){const t=r.samples[e];if(t!=p&&(o.push(t),f<c?u.push(c):(u.push(f),c=f)),e===r.samples.length-1)isNaN(p)||(o.push(p),f<c?u.push(c):(u.push(f),c=f));else{f+=r.timeDeltas[e+1],p=t}}let d=[];for(let e=0;e<o.length;e++){const n=u[e],r=o[e];let f=l.get(r);if(!f)continue;let c=null;for(c=f;c&&-1===d.indexOf(c);c=m(c.callFrame.functionName)?(0,t.lastOf)(d):c.parent||null);for(;d.length>0&&(0,t.lastOf)(d)!=c;){const e=s(d.pop().callFrame);i.leaveFrame(e,n)}const p=[];for(let e=f;e&&e!=c&&!a(e.callFrame);e=m(e.callFrame.functionName)?(0,t.lastOf)(d):e.parent||null)p.push(e);p.reverse();for(let e of p)i.enterFrame(s(e.callFrame),n);d=d.concat(p)}for(let e=d.length-1;e>=0;e--)i.leaveFrame(s(d[e].callFrame),(0,t.lastOf)(u));return i.setValueFormatter(new n.TimeFormatter("microseconds")),i.build()}function f(e){return u((0,r.chromeTreeToNodes)(e))}
5
5
  },{"../lib/profile":"YG8z","../lib/utils":"ucYa","../lib/value-formatters":"LsM4","./v8cpuFormatter":"y1V0"}],"I37H":[function(require,module,exports) {
6
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.importFromStackprof=r;var e=require("../lib/profile"),t=require("../lib/value-formatters");function r(r){const o=r.raw_timestamp_deltas.reduce((e,t)=>e+t,0),a=new e.StackListProfileBuilder(o),{frames:l,raw:s,raw_timestamp_deltas:i}=r;let n=0,c=[];for(let e=0;e<s.length;){const t=s[e++];let r=[];for(let a=0;a<t;a++){const t=s[e++];r.push(Object.assign({key:t},l[t]))}1===r.length&&"(garbage collection)"===r[0].name&&(r=c.concat(r));const o=s[e++];let m=0;for(let e=0;e<o;e++)m+=i[n++];a.appendSampleWithWeight(r,m),c=r}return a.setValueFormatter(new t.TimeFormatter("microseconds")),a.build()}
6
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.importFromStackprof=r;var e=require("../lib/profile"),t=require("../lib/value-formatters");function r(r){const{frames:a,mode:o,raw:l,raw_timestamp_deltas:s,samples:i}=r,n="object"==o,c=n?i:r.raw_timestamp_deltas.reduce((e,t)=>e+t,0),m=new e.StackListProfileBuilder(c);let p=0,u=[];for(let e=0;e<l.length;){const t=l[e++];let r=[];for(let s=0;s<t;s++){const t=l[e++];r.push(Object.assign({key:t},a[t]))}1===r.length&&"(garbage collection)"===r[0].name&&(r=u.concat(r));const o=l[e++];if(n)m.appendSampleWithWeight(r,o);else{let e=0;for(let t=0;t<o;t++)e+=s[p++];m.appendSampleWithWeight(r,e)}u=r}return n||m.setValueFormatter(new t.TimeFormatter("microseconds")),m.build()}
7
7
  },{"../lib/profile":"YG8z","../lib/value-formatters":"LsM4"}],"tbG5":[function(require,module,exports) {
8
8
  "use strict";var r="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;function t(r,t){return Object.prototype.hasOwnProperty.call(r,t)}exports.assign=function(r){for(var e=Array.prototype.slice.call(arguments,1);e.length;){var n=e.shift();if(n){if("object"!=typeof n)throw new TypeError(n+"must be non-object");for(var a in n)t(n,a)&&(r[a]=n[a])}}return r},exports.shrinkBuf=function(r,t){return r.length===t?r:r.subarray?r.subarray(0,t):(r.length=t,r)};var e={arraySet:function(r,t,e,n,a){if(t.subarray&&r.subarray)r.set(t.subarray(e,e+n),a);else for(var o=0;o<n;o++)r[a+o]=t[e+o]},flattenChunks:function(r){var t,e,n,a,o,s;for(n=0,t=0,e=r.length;t<e;t++)n+=r[t].length;for(s=new Uint8Array(n),a=0,t=0,e=r.length;t<e;t++)o=r[t],s.set(o,a),a+=o.length;return s}},n={arraySet:function(r,t,e,n,a){for(var o=0;o<n;o++)r[a+o]=t[e+o]},flattenChunks:function(r){return[].concat.apply([],r)}};exports.setTyped=function(r){r?(exports.Buf8=Uint8Array,exports.Buf16=Uint16Array,exports.Buf32=Int32Array,exports.assign(exports,e)):(exports.Buf8=Array,exports.Buf16=Array,exports.Buf32=Array,exports.assign(exports,n))},exports.setTyped(r);
9
9
  },{}],"sRJQ":[function(require,module,exports) {
@@ -36,22 +36,24 @@ parcelRequire=function(e,r,t,n){var i,o="function"==typeof parcelRequire&&parcel
36
36
  "use strict";var t=require("./zlib/inflate"),i=require("./utils/common"),n=require("./utils/strings"),s=require("./zlib/constants"),r=require("./zlib/messages"),e=require("./zlib/zstream"),o=require("./zlib/gzheader"),u=Object.prototype.toString;function a(n){if(!(this instanceof a))return new a(n);this.options=i.assign({chunkSize:16384,windowBits:0,to:""},n||{});var u=this.options;u.raw&&u.windowBits>=0&&u.windowBits<16&&(u.windowBits=-u.windowBits,0===u.windowBits&&(u.windowBits=-15)),!(u.windowBits>=0&&u.windowBits<16)||n&&n.windowBits||(u.windowBits+=32),u.windowBits>15&&u.windowBits<48&&0==(15&u.windowBits)&&(u.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new e,this.strm.avail_out=0;var h=t.inflateInit2(this.strm,u.windowBits);if(h!==s.Z_OK)throw new Error(r[h]);this.header=new o,t.inflateGetHeader(this.strm,this.header)}function h(t,i){var n=new a(i);if(n.push(t,!0),n.err)throw n.msg||r[n.err];return n.result}function _(t,i){return(i=i||{}).raw=!0,h(t,i)}a.prototype.push=function(r,e){var o,a,h,_,w,l,d=this.strm,f=this.options.chunkSize,p=this.options.dictionary,c=!1;if(this.ended)return!1;a=e===~~e?e:!0===e?s.Z_FINISH:s.Z_NO_FLUSH,"string"==typeof r?d.input=n.binstring2buf(r):"[object ArrayBuffer]"===u.call(r)?d.input=new Uint8Array(r):d.input=r,d.next_in=0,d.avail_in=d.input.length;do{if(0===d.avail_out&&(d.output=new i.Buf8(f),d.next_out=0,d.avail_out=f),(o=t.inflate(d,s.Z_NO_FLUSH))===s.Z_NEED_DICT&&p&&(l="string"==typeof p?n.string2buf(p):"[object ArrayBuffer]"===u.call(p)?new Uint8Array(p):p,o=t.inflateSetDictionary(this.strm,l)),o===s.Z_BUF_ERROR&&!0===c&&(o=s.Z_OK,c=!1),o!==s.Z_STREAM_END&&o!==s.Z_OK)return this.onEnd(o),this.ended=!0,!1;d.next_out&&(0!==d.avail_out&&o!==s.Z_STREAM_END&&(0!==d.avail_in||a!==s.Z_FINISH&&a!==s.Z_SYNC_FLUSH)||("string"===this.options.to?(h=n.utf8border(d.output,d.next_out),_=d.next_out-h,w=n.buf2string(d.output,h),d.next_out=_,d.avail_out=f-_,_&&i.arraySet(d.output,d.output,h,_,0),this.onData(w)):this.onData(i.shrinkBuf(d.output,d.next_out)))),0===d.avail_in&&0===d.avail_out&&(c=!0)}while((d.avail_in>0||0===d.avail_out)&&o!==s.Z_STREAM_END);return o===s.Z_STREAM_END&&(a=s.Z_FINISH),a===s.Z_FINISH?(o=t.inflateEnd(this.strm),this.onEnd(o),this.ended=!0,o===s.Z_OK):a!==s.Z_SYNC_FLUSH||(this.onEnd(s.Z_OK),d.avail_out=0,!0)},a.prototype.onData=function(t){this.chunks.push(t)},a.prototype.onEnd=function(t){t===s.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=i.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg},exports.Inflate=a,exports.inflate=h,exports.inflateRaw=_,exports.ungzip=h;
37
37
  },{"./zlib/inflate":"GIDK","./utils/common":"tbG5","./utils/strings":"Q3ZD","./zlib/constants":"xUUw","./zlib/messages":"gMAY","./zlib/zstream":"bdtv","./zlib/gzheader":"WIli"}],"f4vO":[function(require,module,exports) {
38
38
  "use strict";var e=require("./lib/utils/common").assign,i=require("./lib/deflate"),r=require("./lib/inflate"),l=require("./lib/zlib/constants"),s={};e(s,i,r,l),module.exports=s;
39
- },{"./lib/utils/common":"tbG5","./lib/deflate":"nFS2","./lib/inflate":"faQk","./lib/zlib/constants":"xUUw"}],"QTYz":[function(require,module,exports) {
40
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.MaybeCompressedDataReader=exports.TextProfileDataSource=void 0;var e=t(require("pako"));function r(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return r=function(){return e},e}function t(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=r();if(t&&t.has(e))return t.get(e);var n={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e)if(Object.prototype.hasOwnProperty.call(e,i)){var s=o?Object.getOwnPropertyDescriptor(e,i):null;s&&(s.get||s.set)?Object.defineProperty(n,i,s):n[i]=e[i]}return n.default=e,t&&t.set(e,n),n}var n=function(e,r,t,n){return new(t||(t=Promise))(function(o,i){function s(e){try{u(n.next(e))}catch(r){i(r)}}function a(e){try{u(n.throw(e))}catch(r){i(r)}}function u(e){var r;e.done?o(e.value):(r=e.value,r instanceof t?r:new t(function(e){e(r)})).then(s,a)}u((n=n.apply(e,r||[])).next())})};class o{constructor(e,r){this.fileName=e,this.contents=r}name(){return n(this,void 0,void 0,function*(){return this.fileName})}readAsArrayBuffer(){return n(this,void 0,void 0,function*(){return new ArrayBuffer(0)})}readAsText(){return n(this,void 0,void 0,function*(){return this.contents})}}exports.TextProfileDataSource=o;class i{constructor(r,t){this.namePromise=r,this.uncompressedData=t.then(r=>n(this,void 0,void 0,function*(){try{return e.inflate(new Uint8Array(r)).buffer}catch(t){return r}}))}name(){return n(this,void 0,void 0,function*(){return yield this.namePromise})}readAsArrayBuffer(){return n(this,void 0,void 0,function*(){return yield this.uncompressedData})}readAsText(){return n(this,void 0,void 0,function*(){const e=yield this.readAsArrayBuffer();let r="utf-8";const t=new Uint8Array(e);if(t.length>2&&(255===t[0]&&254===t[1]?r="utf-16le":254===t[0]&&255===t[1]&&(r="utf-16be")),"undefined"!=typeof TextDecoder){return new TextDecoder(r).decode(e)}{console.warn("This browser does not support TextDecoder. Decoding text as ASCII.");let e="";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e}})}static fromFile(e){const r=new Promise(r=>{const t=new FileReader;t.addEventListener("loadend",()=>{if(!(t.result instanceof ArrayBuffer))throw new Error("Expected reader.result to be an instance of ArrayBuffer");r(t.result)}),t.readAsArrayBuffer(e)});return new i(Promise.resolve(e.name),r)}static fromArrayBuffer(e,r){return new i(Promise.resolve(e),Promise.resolve(r))}}exports.MaybeCompressedDataReader=i;
41
- },{"pako":"f4vO"}],"G28U":[function(require,module,exports) {
42
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.importFromInstrumentsDeepCopy=a,exports.importFromInstrumentsTrace=w,exports.importRunFromInstrumentsTrace=g,exports.importThreadFromInstrumentsTrace=b,exports.readInstrumentsKeyedArchive=y,exports.decodeUTF8=v,exports.UID=void 0;var e=require("../lib/profile"),t=require("../lib/utils"),r=require("../lib/value-formatters"),n=require("./utils"),s=function(e,t,r,n){return new(r||(r=Promise))(function(s,i){function o(e){try{l(n.next(e))}catch(t){i(t)}}function a(e){try{l(n.throw(e))}catch(t){i(t)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(o,a)}l((n=n.apply(e,t||[])).next())})};function i(e){const t=e.split("\n").map(e=>e.split("\t")),r=t.shift();if(!r)return[];const n=new Map;for(let i=0;i<r.length;i++)n.set(i,r[i]);const s=[];for(let i of t){const e={};for(let t=0;t<i.length;t++)e[n.get(t)]=i[t];s.push(e)}return s}function o(e){if("Bytes Used"in e){const t=e["Bytes Used"],r=/\s*(\d+(?:[.]\d+)?) (\w+)\s+(?:\d+(?:[.]\d+))%/.exec(t);if(!r)return 0;const n=parseInt(r[1],10),s=r[2];switch(s){case"Bytes":return n;case"KB":return 1024*n;case"MB":return 1048576*n;case"GB":return 1073741824*n}throw new Error(`Unrecognized units ${s}`)}if("Weight"in e||"Running Time"in e){const t=e.Weight||e["Running Time"],r=/\s*(\d+(?:[.]\d+)?) ?(\w+)\s+(?:\d+(?:[.]\d+))%/.exec(t);if(!r)return 0;const n=parseInt(r[1],10),s=r[2];switch(s){case"ms":return n;case"s":case"min":return 1e3*n}throw new Error(`Unrecognized units ${s}`)}return-1}function a(t){const n=new e.CallTreeProfileBuilder,s=i(t),a=[];let l=0;for(let e of s){const t=e["Symbol Name"];if(!t)continue;const r=t.trim();let s=t.length-r.length;if(a.length-s<0)throw new Error("Invalid format");let i=[];for(;s<a.length;){const e=a.pop();i.push(e)}for(let e of i)l=Math.max(l,e.endValue),n.leaveFrame(e,l);const c={key:`${e["Source Path"]||""}:${r}`,name:r,file:e["Source Path"],endValue:l+o(e)};n.enterFrame(c,l),a.push(c)}for(;a.length>0;){const e=a.pop();l=Math.max(l,e.endValue),n.leaveFrame(e,l)}return"Bytes Used"in s[0]?n.setValueFormatter(new r.ByteFormatter):("Weight"in s[0]||"Running Time"in s[0])&&n.setValueFormatter(new r.TimeFormatter("milliseconds")),n.build()}function l(e){return s(this,void 0,void 0,function*(){const t={name:e.name,files:new Map,subdirectories:new Map},r=yield new Promise((t,r)=>{e.createReader().readEntries(e=>{t(e)},r)});for(let e of r)if(e.isDirectory){const r=yield l(e);t.subdirectories.set(r.name,r)}else{const r=yield new Promise((t,r)=>{e.file(t,r)});t.files.set(r.name,r)}return t})}function c(e){return n.MaybeCompressedDataReader.fromFile(e).readAsArrayBuffer()}function u(e){return n.MaybeCompressedDataReader.fromFile(e).readAsText()}function f(e,r){const n=(0,t.getOrThrow)(e.subdirectories,"corespace"),s=(0,t.getOrThrow)(n.subdirectories,`run${r}`);return(0,t.getOrThrow)(s.subdirectories,"core")}class h{constructor(e){this.bytePos=0,this.view=new DataView(e)}seek(e){this.bytePos=e}skip(e){this.bytePos+=e}hasMore(){return this.bytePos<this.view.byteLength}bytesLeft(){return this.view.byteLength-this.bytePos}readUint8(){return this.bytePos++,this.bytePos>this.view.byteLength?0:this.view.getUint8(this.bytePos-1)}readUint32(){return this.bytePos+=4,this.bytePos>this.view.byteLength?0:this.view.getUint32(this.bytePos-4,!0)}readUint48(){return this.bytePos+=6,this.bytePos>this.view.byteLength?0:this.view.getUint32(this.bytePos-6,!0)+this.view.getUint16(this.bytePos-2,!0)*Math.pow(2,32)}readUint64(){return this.bytePos+=8,this.bytePos>this.view.byteLength?0:this.view.getUint32(this.bytePos-8,!0)+this.view.getUint32(this.bytePos-4,!0)*Math.pow(2,32)}}function p(e){return s(this,void 0,void 0,function*(){const r=(0,t.getOrThrow)(e.subdirectories,"stores");for(let e of r.subdirectories.values()){const r=e.files.get("schema.xml");if(!r)continue;const n=yield u(r);if(!/name="time-profile"/.exec(n))continue;const s=new h(yield c((0,t.getOrThrow)(e.files,"bulkstore")));s.readUint32(),s.readUint32(),s.readUint32();const i=s.readUint32(),o=s.readUint32();s.seek(i);const a=[];for(;;){const e=s.readUint48();if(0===e)break;const t=s.readUint32();s.skip(o-6-4-4);const r=s.readUint32();a.push({timestamp:e,threadID:t,backtraceID:r})}return a}throw new Error("Could not find sample list")})}function d(e,r){return s(this,void 0,void 0,function*(){const e=(0,t.getOrThrow)(r.subdirectories,"uniquing"),n=(0,t.getOrThrow)(e.subdirectories,"arrayUniquer"),s=(0,t.getOrThrow)(n.files,"integeruniquer.index"),i=(0,t.getOrThrow)(n.files,"integeruniquer.data"),o=new h(yield c(s)),a=new h(yield c(i));o.seek(32);let l=[];for(;o.hasMore();){const e=o.readUint32()+1048576*o.readUint32();if(0===e)continue;a.seek(e);let t=a.readUint32(),r=[];for(;t--;)r.push(a.readUint64());l.push(r)}return l})}function m(e){return s(this,void 0,void 0,function*(){const r=(0,t.getOrThrow)(e.files,"form.template"),n=y(yield c(r)),s=n["com.apple.xray.owner.template.version"];let i=1;"com.apple.xray.owner.template"in n&&(i=n["com.apple.xray.owner.template"].get("_selectedRunNumber"));let o=n.$1;"stubInfoByUUID"in n&&(o=Array.from(n.stubInfoByUUID.keys())[0]);const a=n["com.apple.xray.run.data"],l=[];for(let e of a.runNumbers){const r=(0,t.getOrThrow)(a.runData,e),n=(0,t.getOrThrow)(r,"symbolsByPid"),s=new Map;for(let i of n.values()){for(let e of i.symbols){if(!e)continue;const{sourcePath:r,symbolName:n,addressToLine:i}=e;for(let e of i.keys())(0,t.getOrInsert)(s,e,()=>{const s=n||`0x${(0,t.zeroPad)(e.toString(16),16)}`,i={key:`${r}:${s}`,name:s};return r&&(i.file=r),i})}l.push({number:e,addressToFrameMap:s})}}return{version:s,instrument:o,selectedRunNumber:i,runs:l}})}function w(e){return s(this,void 0,void 0,function*(){const t=yield l(e),{version:r,runs:n,instrument:s,selectedRunNumber:i}=yield m(t);if("com.apple.xray.instrument-type.coresampler2"!==s)throw new Error(`The only supported instrument from .trace import is "com.apple.xray.instrument-type.coresampler2". Got ${s}`);console.log("version: ",r),console.log("Importing time profile");const o=[];let a=0;for(let l of n){const{addressToFrameMap:r,number:n}=l,s=yield g({fileName:e.name,tree:t,addressToFrameMap:r,runNumber:n});l.number===i&&(a=o.length+s.indexToView),o.push(...s.profiles)}return{name:e.name,indexToView:a,profiles:o}})}function g(e){return s(this,void 0,void 0,function*(){const{fileName:r,tree:n,addressToFrameMap:s,runNumber:i}=e,o=f(n,i);let a=yield p(o);const l=yield d(a,o),c=new Map;for(let e of a)c.set(e.threadID,(0,t.getOrElse)(c,e.threadID,()=>0)+1);const u=Array.from(c.entries());(0,t.sortBy)(u,e=>-e[1]);const h=u.map(e=>e[0]);return{name:r,indexToView:0,profiles:h.map(e=>b({threadID:e,fileName:r,arrays:l,addressToFrameMap:s,samples:a}))}})}function b(n){let{fileName:s,addressToFrameMap:i,arrays:o,threadID:a,samples:l}=n;const c=new Map;l=l.filter(e=>e.threadID===a);const u=new e.StackListProfileBuilder((0,t.lastOf)(l).timestamp);function f(e,r){const n=i.get(e);if(n)r.push(n);else if(e in o)for(let t of o[e])f(t,r);else{const n={key:e,name:`0x${(0,t.zeroPad)(e.toString(16),16)}`};i.set(e,n),r.push(n)}}u.setName(`${s} - thread ${a}`);let h=null;for(let e of l){const r=(0,t.getOrInsert)(c,e.backtraceID,e=>{const t=[];return f(e,t),t.reverse(),t});if(null===h&&(u.appendSampleWithWeight([],e.timestamp),h=e.timestamp),e.timestamp<h)throw new Error("Timestamps out of order!");u.appendSampleWithWeight(r,e.timestamp-h),h=e.timestamp}return u.setValueFormatter(new r.TimeFormatter("nanoseconds")),u.build()}function y(e){return T(I(new Uint8Array(e)),(e,t)=>{switch(e){case"NSTextStorage":case"NSParagraphStyle":case"NSFont":return null;case"PFTSymbolData":{const e=Object.create(null);e.symbolName=t.$0,e.sourcePath=t.$1,e.addressToLine=new Map;for(let r=3;;r+=2){const n=t["$"+r],s=t["$"+(r+1)];if(null==n||null==s)break;e.addressToLine.set(n,s)}return e}case"PFTOwnerData":{const e=Object.create(null);return e.ownerName=t.$0,e.ownerPath=t.$1,e}case"PFTPersistentSymbols":{const e=Object.create(null),r=t.$4;e.threadNames=t.$3,e.symbols=[];for(let n=1;n<r;n++)e.symbols.push(t["$"+(4+n)]);return e}case"XRRunListData":{const e=Object.create(null);return e.runNumbers=t.$0,e.runData=t.$1,e}case"XRIntKeyedDictionary":{const e=new Map,r=t.$0;for(let n=0;n<r;n++){const r=t["$"+(1+2*n)],s=t["$"+(2*n+1+1)];e.set(r,s)}return e}case"XRCore":{const e=Object.create(null);return e.number=t.$0,e.name=t.$1,e}}return t})}function v(e){let t=String.fromCharCode.apply(String,Array.from(e));return"\0"===t.slice(-1)&&(t=t.slice(0,-1)),decodeURIComponent(escape(t))}function U(e){return e instanceof Array}function S(e){return null!==e&&"object"==typeof e&&null===Object.getPrototypeOf(e)}function N(e,t){return t instanceof x?e[t.index]:t}function T(e,t=(e=>e)){if(1e5!==e.$version||"NSKeyedArchiver"!==e.$archiver||!S(e.$top)||!U(e.$objects))throw new Error("Invalid keyed archive");"$null"===e.$objects[0]&&(e.$objects[0]=null);for(let n=0;n<e.$objects.length;n++)e.$objects[n]=$(e.$objects,e.$objects[n],t);let r=t=>{if(t instanceof x)return e.$objects[t.index];if(U(t))for(let e=0;e<t.length;e++)t[e]=r(t[e]);else if(S(t))for(let e in t)t[e]=r(t[e]);else if(t instanceof Map){const e=new Map(t);t.clear();for(let[n,s]of e.entries())t.set(r(n),r(s))}return t};for(let n=0;n<e.$objects.length;n++)r(e.$objects[n]);return r(e.$top)}function $(e,t,r=(e=>e)){if(S(t)&&t.$class){let n=N(e,t.$class).$classname;switch(n){case"NSDecimalNumberPlaceholder":{let e=t["NS.length"],r=t["NS.exponent"],n=t["NS.mantissa.bo"],s=t["NS.negative"],i=new Uint16Array(new Uint8Array(t["NS.mantissa"]).buffer),o=0;for(let t=0;t<e;t++){let e=i[t];1!==n&&(e=(65280&e)>>8|(255&e)<<8),o+=e*Math.pow(65536,t)}return o*=Math.pow(10,r),s?-o:o}case"NSData":case"NSMutableData":return t["NS.bytes"]||t["NS.data"];case"NSString":case"NSMutableString":return t["NS.string"]?t["NS.string"]:t["NS.bytes"]?v(t["NS.bytes"]):(console.warn(`Unexpected ${n} format: `,t),null);case"NSArray":case"NSMutableArray":if("NS.objects"in t)return t["NS.objects"];let e=[];for(;;){let r="NS.object."+e.length;if(!(r in t))break;e.push(t[r])}return e;case"_NSKeyedCoderOldStyleArray":{const e=t["NS.count"];let r=[];for(let n=0;n<e;n++){const e=t["$"+n];r.push(e)}return r}case"NSDictionary":case"NSMutableDictionary":let s=new Map;if("NS.keys"in t&&"NS.objects"in t)for(let r=0;r<t["NS.keys"].length;r++)s.set(t["NS.keys"][r],t["NS.objects"][r]);else for(;;){let e="NS.key."+s.size,r="NS.object."+s.size;if(!(e in t&&r in t))break;s.set(t[e],t[r])}return s;default:const i=r(n,t);if(i!==t)return i}}return t}class x{constructor(e){this.index=e}}function I(e){for(let t=0;t<8;t++)if(e[t]!=="bplist00".charCodeAt(t))throw new Error("File is not a binary plist");return new P(new DataView(e.buffer,e.byteOffset,e.byteLength)).parseRoot()}exports.UID=x;class P{constructor(e){this.view=e,this.referenceSize=0,this.objects=[],this.offsetTable=[]}parseRoot(){let e=this.view.byteLength-32,t=this.view.getUint8(e+6);this.referenceSize=this.view.getUint8(e+7);let r=this.view.getUint32(e+12,!1),n=this.view.getUint32(e+20,!1),s=this.view.getUint32(e+28,!1);for(let i=0;i<r;i++)this.offsetTable.push(this.parseInteger(s,t)),s+=t;return this.parseObject(this.offsetTable[n])}parseLengthAndOffset(e,t){if(15!==t)return{length:t,offset:0};let r=this.view.getUint8(e++);if(16!=(240&r))throw new Error("Unexpected non-integer length at offset "+e);let n=1<<(15&r);return{length:this.parseInteger(e,n),offset:n+1}}parseSingleton(e,t){if(0===t)return null;if(8===t)return!1;if(9===t)return!0;throw new Error("Unexpected extra value "+t+" at offset "+e)}parseInteger(e,t){if(1===t)return this.view.getUint8(e);if(2===t)return this.view.getUint16(e,!1);if(4===t)return this.view.getUint32(e,!1);if(8===t)return Math.pow(2,32)*this.view.getUint32(e+0,!1)+Math.pow(2,0)*this.view.getUint32(e+4,!1);if(16===t)return Math.pow(2,96)*this.view.getUint32(e+0,!1)+Math.pow(2,64)*this.view.getUint32(e+4,!1)+Math.pow(2,32)*this.view.getUint32(e+8,!1)+Math.pow(2,0)*this.view.getUint32(e+12,!1);throw new Error("Unexpected integer of size "+t+" at offset "+e)}parseFloat(e,t){if(4===t)return this.view.getFloat32(e,!1);if(8===t)return this.view.getFloat64(e,!1);throw new Error("Unexpected float of size "+t+" at offset "+e)}parseDate(e,t){if(8!==t)throw new Error("Unexpected date of size "+t+" at offset "+e);let r=this.view.getFloat64(e,!1);return new Date(9783072e5+1e3*r)}parseData(e,t){let r=this.parseLengthAndOffset(e,t);return new Uint8Array(this.view.buffer,e+r.offset,r.length)}parseStringASCII(e,t){let r=this.parseLengthAndOffset(e,t),n="";e+=r.offset;for(let s=0;s<r.length;s++)n+=String.fromCharCode(this.view.getUint8(e++));return n}parseStringUTF16(e,t){let r=this.parseLengthAndOffset(e,t),n="";e+=r.offset;for(let s=0;s<r.length;s++)n+=String.fromCharCode(this.view.getUint16(e,!1)),e+=2;return n}parseUID(e,t){return new x(this.parseInteger(e,t))}parseArray(e,t){let r=this.parseLengthAndOffset(e,t),n=[],s=this.referenceSize;e+=r.offset;for(let i=0;i<r.length;i++)n.push(this.parseObject(this.offsetTable[this.parseInteger(e,s)])),e+=s;return n}parseDictionary(e,t){let r=this.parseLengthAndOffset(e,t),n=Object.create(null),s=this.referenceSize,i=e+r.offset,o=i+r.length*s;for(let a=0;a<r.length;a++){let e=this.parseObject(this.offsetTable[this.parseInteger(i,s)]),t=this.parseObject(this.offsetTable[this.parseInteger(o,s)]);if("string"!=typeof e)throw new Error("Unexpected non-string key at offset "+i);n[e]=t,i+=s,o+=s}return n}parseObject(e){let t=this.view.getUint8(e++),r=15&t;switch(t>>4){case 0:return this.parseSingleton(e,r);case 1:return this.parseInteger(e,1<<r);case 2:return this.parseFloat(e,1<<r);case 3:return this.parseDate(e,1<<r);case 4:return this.parseData(e,r);case 5:return this.parseStringASCII(e,r);case 6:return this.parseStringUTF16(e,r);case 8:return this.parseUID(e,r+1);case 10:return this.parseArray(e,r);case 13:return this.parseDictionary(e,r)}throw new Error("Unexpected marker "+t+" at offset "+--e)}}
39
+ },{"./lib/utils/common":"tbG5","./lib/deflate":"nFS2","./lib/inflate":"faQk","./lib/zlib/constants":"xUUw"}],"DstG":[function(require,module,exports) {
40
+ !function(e){var a=String.fromCharCode;function s(e,s,c){for(var n=e[s],r=1,i=0,t=0;t<s;t++)10===e[t]?(r++,i=0):i++;throw new SyntaxError(c||(s===e.length?"Unexpected end of input while parsing JSON":n>=32&&n<=126?"Unexpected character "+a(n)+" in JSON at position "+s+" (line "+r+", column "+i+")":"Unexpected byte 0x"+n.toString(16)+" in JSON at position "+s+" (line "+r+", column "+i+")"))}e.JSON_parse=function(e){if(!(e instanceof Uint8Array))throw new Error("JSON input must be a Uint8Array");for(var c,n=[],r=[],i=[],t=e.length,o=null,u=0,f=0;f<t;){var p=e[f++];if(!(p<=32)){var l=void 0;switch(2===u&&null===o&&34!==p&&125!==p&&s(e,--f),p){case 116:114===e[f++]&&117===e[f++]&&101===e[f++]||s(e,--f),l=!0;break;case 102:97===e[f++]&&108===e[f++]&&115===e[f++]&&101===e[f++]||s(e,--f),l=!1;break;case 110:117===e[f++]&&108===e[f++]&&108===e[f++]||s(e,--f),l=null;break;case 45:case 46:case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:var b=f;for(l=a(p),p=e[f];;){switch(p){case 43:case 45:case 46:case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:case 101:case 69:l+=a(p),p=e[++f];continue}break}l=+l,isNaN(l)&&s(e,--b,"Invalid number");break;case 34:for(l="";f>=t&&s(e,t),34!==(p=e[f++]);)if(92===p)switch(e[f++]){case 34:l+='"';break;case 47:l+="/";break;case 92:l+="\\";break;case 98:l+="\b";break;case 102:l+="\f";break;case 110:l+="\n";break;case 114:l+="\r";break;case 116:l+="\t";break;case 117:for(var k=0,h=0;h<4;h++)k<<=4,(p=e[f++])>=48&&p<=57?k|=p-48:p>=97&&p<=102?k|=p+-87:p>=65&&p<=70?k|=p+-55:s(e,--f);l+=a(k);break;default:s(e,--f)}else if(p<=127)l+=a(p);else if(192==(224&p))l+=a((31&p)<<6|63&e[f++]);else if(224==(240&p))l+=a((15&p)<<12|(63&e[f++])<<6|63&e[f++]);else if(240==(248&p)){var d=(7&p)<<18|(63&e[f++])<<12|(63&e[f++])<<6|63&e[f++];d>65535&&(l+=a((d-=65536)>>10&1023|55296),d=56320|1023&d),l+=a(d)}l[0];break;case 91:l=[],n.push(o),r.push(c),i.push(u),o=null,c=l,u=1;continue;case 123:l={},n.push(o),r.push(c),i.push(u),o=null,c=l,u=2;continue;case 93:1!==u&&s(e,--f),l=c,o=n.pop(),c=r.pop(),u=i.pop();break;case 125:2!==u&&s(e,--f),l=c,o=n.pop(),c=r.pop(),u=i.pop();break;default:s(e,--f)}for(p=e[f];p<=32;)p=e[++f];switch(u){case 0:if(f===t)return l;break;case 1:if(c.push(l),44===p){f++;continue}if(93===p)continue;break;case 2:if(null===o){if(o=l,58===p){f++;continue}}else{if(c[o]=l,o=null,44===p){f++;continue}if(125===p)continue}}break}}s(e,f)}}("undefined"!=typeof exports?exports:this);
41
+ },{}],"QTYz":[function(require,module,exports) {
42
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.withMockedFileChunkSizeForTests=o,exports.MaybeCompressedDataReader=exports.TextProfileDataSource=exports.StringBackedTextFileContent=exports.BufferBackedTextFileContent=void 0;var e=n(require("pako")),t=require("uint8array-json-parser");function r(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return r=function(){return e},e}function n(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=r();if(t&&t.has(e))return t.get(e);var n={},s=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e)if(Object.prototype.hasOwnProperty.call(e,i)){var o=s?Object.getOwnPropertyDescriptor(e,i):null;o&&(o.get||o.set)?Object.defineProperty(n,i,o):n[i]=e[i]}return n.default=e,t&&t.set(e,n),n}var s=function(e,t,r,n){return new(r||(r=Promise))(function(s,i){function o(e){try{a(n.next(e))}catch(t){i(t)}}function u(e){try{a(n.throw(e))}catch(t){i(t)}}function a(e){var t;e.done?s(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(o,u)}a((n=n.apply(e,t||[])).next())})};let i=1<<27;function o(e,t){return s(this,void 0,void 0,function*(){const r=i;i=e;try{yield t()}finally{i=r}})}function u(e){return"["===(e=e.trim())[0]&&"]"!==(e=e.replace(/,\s*$/,""))[e.length-1]&&(e+="]"),JSON.parse(e)}function a(e){let r=0;for(let t=0;t<e.length;t++)if(!/\s/.exec(String.fromCharCode(e[t]))){r=t;break}if(e[r]==="[".charCodeAt(0)&&e[e.length-1]!=="]".charCodeAt(0)){let t=e.length;for(;t>0&&/\s/.exec(String.fromCharCode(e[t-1]));)t--;if(","===String.fromCharCode(e[t-1])&&t--,"]"!==String.fromCharCode(e[t-1])){const r=new Uint8Array(t+1);r.set(e.subarray(0,t)),r[t]="]".charCodeAt(0),e=r}}return(0,t.JSON_parse)(e)}class c{constructor(e){this.chunks=[];const t=this.byteArray=new Uint8Array(e);let r="utf-8";if(t.length>2&&(255===t[0]&&254===t[1]?r="utf-16le":254===t[0]&&255===t[1]&&(r="utf-16be")),"undefined"!=typeof TextDecoder){const t=new TextDecoder(r);for(let r=0;r<e.byteLength/i;r++){const n=r*i,s=new Uint8Array(e,n,Math.min(e.byteLength-n,i)),o=t.decode(s,{stream:!0});this.chunks.push(o)}}else{console.warn("This browser does not support TextDecoder. Decoding text as ASCII."),this.chunks.push("");for(let e=0;e<t.length;e++)this.chunks[this.chunks.length-1]+=String.fromCharCode(t[e]),this.chunks[this.chunks.length-1],this.chunks[this.chunks.length-1].length>=i&&this.chunks.push("")}}splitLines(){let e=this.chunks[0].split("\n");for(let t=1;t<this.chunks.length;t++){const r=this.chunks[t].split("\n");0!==r.length&&(e.length>0&&(e[e.length-1]+=r.shift()),e=e.concat(r))}return e}firstChunk(){return this.chunks[0]||""}parseAsJSON(){return 1===this.chunks.length?u(this.chunks[0]):a(this.byteArray)}}exports.BufferBackedTextFileContent=c;class h{constructor(e){this.s=e}splitLines(){return this.s.split("\n")}firstChunk(){return this.s}parseAsJSON(){return u(this.s)}}exports.StringBackedTextFileContent=h;class f{constructor(e,t){this.fileName=e,this.contents=t}name(){return s(this,void 0,void 0,function*(){return this.fileName})}readAsArrayBuffer(){return s(this,void 0,void 0,function*(){return new ArrayBuffer(0)})}readAsText(){return s(this,void 0,void 0,function*(){return new h(this.contents)})}}exports.TextProfileDataSource=f;class l{constructor(t,r){this.namePromise=t,this.uncompressedData=r.then(t=>s(this,void 0,void 0,function*(){try{return e.inflate(new Uint8Array(t)).buffer}catch(r){return t}}))}name(){return s(this,void 0,void 0,function*(){return yield this.namePromise})}readAsArrayBuffer(){return s(this,void 0,void 0,function*(){return yield this.uncompressedData})}readAsText(){return s(this,void 0,void 0,function*(){const e=yield this.readAsArrayBuffer();return new c(e)})}static fromFile(e){const t=new Promise(t=>{const r=new FileReader;r.addEventListener("loadend",()=>{if(!(r.result instanceof ArrayBuffer))throw new Error("Expected reader.result to be an instance of ArrayBuffer");t(r.result)}),r.readAsArrayBuffer(e)});return new l(Promise.resolve(e.name),t)}static fromArrayBuffer(e,t){return new l(Promise.resolve(e),Promise.resolve(t))}}exports.MaybeCompressedDataReader=l;
43
+ },{"pako":"f4vO","uint8array-json-parser":"DstG"}],"G28U":[function(require,module,exports) {
44
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.importFromInstrumentsDeepCopy=a,exports.importFromInstrumentsTrace=w,exports.importRunFromInstrumentsTrace=g,exports.importThreadFromInstrumentsTrace=b,exports.readInstrumentsKeyedArchive=y,exports.decodeUTF8=v,exports.UID=void 0;var e=require("../lib/profile"),t=require("../lib/utils"),r=require("../lib/value-formatters"),n=require("./utils"),s=function(e,t,r,n){return new(r||(r=Promise))(function(s,i){function o(e){try{c(n.next(e))}catch(t){i(t)}}function a(e){try{c(n.throw(e))}catch(t){i(t)}}function c(e){var t;e.done?s(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(o,a)}c((n=n.apply(e,t||[])).next())})};function i(e){const t=e.splitLines().map(e=>e.split("\t")),r=t.shift();if(!r)return[];const n=new Map;for(let i=0;i<r.length;i++)n.set(i,r[i]);const s=[];for(let i of t){const e={};for(let t=0;t<i.length;t++)e[n.get(t)]=i[t];s.push(e)}return s}function o(e){if("Bytes Used"in e){const t=e["Bytes Used"],r=/\s*(\d+(?:[.]\d+)?) (\w+)\s+(?:\d+(?:[.]\d+))%/.exec(t);if(!r)return 0;const n=parseInt(r[1],10),s=r[2];switch(s){case"Bytes":return n;case"KB":return 1024*n;case"MB":return 1048576*n;case"GB":return 1073741824*n}throw new Error(`Unrecognized units ${s}`)}if("Weight"in e||"Running Time"in e){const t=e.Weight||e["Running Time"],r=/\s*(\d+(?:[.]\d+)?) ?(\w+)\s+(?:\d+(?:[.]\d+))%/.exec(t);if(!r)return 0;const n=parseInt(r[1],10),s=r[2];switch(s){case"ms":return n;case"s":return 1e3*n;case"min":return 6e4*n;case"cycles":return n;case"Kc":return 1e3*n;case"Mc":return 1e6*n;case"Gc":return 1e9*n}throw new Error(`Unrecognized units ${s}`)}return-1}function a(t){const n=new e.CallTreeProfileBuilder,s=i(t),a=[];let c=0;for(let e of s){const t=e["Symbol Name"];if(!t)continue;const r=t.trim();let s=t.length-r.length;if(a.length-s<0)throw new Error("Invalid format");let i=[];for(;s<a.length;){const e=a.pop();i.push(e)}for(let e of i)c=Math.max(c,e.endValue),n.leaveFrame(e,c);const l={key:`${e["Source Path"]||""}:${r}`,name:r,file:e["Source Path"],endValue:c+o(e)};n.enterFrame(l,c),a.push(l)}for(;a.length>0;){const e=a.pop();c=Math.max(c,e.endValue),n.leaveFrame(e,c)}return"Bytes Used"in s[0]?n.setValueFormatter(new r.ByteFormatter):("Weight"in s[0]||"Running Time"in s[0])&&n.setValueFormatter(new r.TimeFormatter("milliseconds")),n.build()}function c(e){return s(this,void 0,void 0,function*(){const t={name:e.name,files:new Map,subdirectories:new Map},r=yield new Promise((t,r)=>{e.createReader().readEntries(e=>{t(e)},r)});for(let e of r)if(e.isDirectory){const r=yield c(e);t.subdirectories.set(r.name,r)}else{const r=yield new Promise((t,r)=>{e.file(t,r)});t.files.set(r.name,r)}return t})}function l(e){return n.MaybeCompressedDataReader.fromFile(e).readAsArrayBuffer()}function u(e){return n.MaybeCompressedDataReader.fromFile(e).readAsText()}function f(e,r){const n=(0,t.getOrThrow)(e.subdirectories,"corespace"),s=(0,t.getOrThrow)(n.subdirectories,`run${r}`);return(0,t.getOrThrow)(s.subdirectories,"core")}class h{constructor(e){this.bytePos=0,this.view=new DataView(e)}seek(e){this.bytePos=e}skip(e){this.bytePos+=e}hasMore(){return this.bytePos<this.view.byteLength}bytesLeft(){return this.view.byteLength-this.bytePos}readUint8(){return this.bytePos++,this.bytePos>this.view.byteLength?0:this.view.getUint8(this.bytePos-1)}readUint32(){return this.bytePos+=4,this.bytePos>this.view.byteLength?0:this.view.getUint32(this.bytePos-4,!0)}readUint48(){return this.bytePos+=6,this.bytePos>this.view.byteLength?0:this.view.getUint32(this.bytePos-6,!0)+this.view.getUint16(this.bytePos-2,!0)*Math.pow(2,32)}readUint64(){return this.bytePos+=8,this.bytePos>this.view.byteLength?0:this.view.getUint32(this.bytePos-8,!0)+this.view.getUint32(this.bytePos-4,!0)*Math.pow(2,32)}}function p(e){return s(this,void 0,void 0,function*(){const r=(0,t.getOrThrow)(e.subdirectories,"stores");for(let e of r.subdirectories.values()){const r=e.files.get("schema.xml");if(!r)continue;const n=yield u(r);if(!/name="time-profile"/.exec(n.firstChunk()))continue;const s=new h(yield l((0,t.getOrThrow)(e.files,"bulkstore")));s.readUint32(),s.readUint32(),s.readUint32();const i=s.readUint32(),o=s.readUint32();s.seek(i);const a=[];for(;;){const e=s.readUint48();if(0===e)break;const t=s.readUint32();s.skip(o-6-4-4);const r=s.readUint32();a.push({timestamp:e,threadID:t,backtraceID:r})}return a}throw new Error("Could not find sample list")})}function d(e,r){return s(this,void 0,void 0,function*(){const e=(0,t.getOrThrow)(r.subdirectories,"uniquing"),n=(0,t.getOrThrow)(e.subdirectories,"arrayUniquer"),s=(0,t.getOrThrow)(n.files,"integeruniquer.index"),i=(0,t.getOrThrow)(n.files,"integeruniquer.data"),o=new h(yield l(s)),a=new h(yield l(i));o.seek(32);let c=[];for(;o.hasMore();){const e=o.readUint32()+1048576*o.readUint32();if(0===e)continue;a.seek(e);let t=a.readUint32(),r=[];for(;t--;)r.push(a.readUint64());c.push(r)}return c})}function m(e){return s(this,void 0,void 0,function*(){const r=(0,t.getOrThrow)(e.files,"form.template"),n=y(yield l(r)),s=n["com.apple.xray.owner.template.version"];let i=1;"com.apple.xray.owner.template"in n&&(i=n["com.apple.xray.owner.template"].get("_selectedRunNumber"));let o=n.$1;"stubInfoByUUID"in n&&(o=Array.from(n.stubInfoByUUID.keys())[0]);const a=n["com.apple.xray.run.data"],c=[];for(let e of a.runNumbers){const r=(0,t.getOrThrow)(a.runData,e),n=(0,t.getOrThrow)(r,"symbolsByPid"),s=new Map;for(let i of n.values()){for(let e of i.symbols){if(!e)continue;const{sourcePath:r,symbolName:n,addressToLine:i}=e;for(let e of i.keys())(0,t.getOrInsert)(s,e,()=>{const s=n||`0x${(0,t.zeroPad)(e.toString(16),16)}`,i={key:`${r}:${s}`,name:s};return r&&(i.file=r),i})}c.push({number:e,addressToFrameMap:s})}}return{version:s,instrument:o,selectedRunNumber:i,runs:c}})}function w(e){return s(this,void 0,void 0,function*(){const t=yield c(e),{version:r,runs:n,instrument:s,selectedRunNumber:i}=yield m(t);if("com.apple.xray.instrument-type.coresampler2"!==s)throw new Error(`The only supported instrument from .trace import is "com.apple.xray.instrument-type.coresampler2". Got ${s}`);console.log("version: ",r),console.log("Importing time profile");const o=[];let a=0;for(let c of n){const{addressToFrameMap:r,number:n}=c,s=yield g({fileName:e.name,tree:t,addressToFrameMap:r,runNumber:n});c.number===i&&(a=o.length+s.indexToView),o.push(...s.profiles)}return{name:e.name,indexToView:a,profiles:o}})}function g(e){return s(this,void 0,void 0,function*(){const{fileName:r,tree:n,addressToFrameMap:s,runNumber:i}=e,o=f(n,i);let a=yield p(o);const c=yield d(a,o),l=new Map;for(let e of a)l.set(e.threadID,(0,t.getOrElse)(l,e.threadID,()=>0)+1);const u=Array.from(l.entries());(0,t.sortBy)(u,e=>-e[1]);const h=u.map(e=>e[0]);return{name:r,indexToView:0,profiles:h.map(e=>b({threadID:e,fileName:r,arrays:c,addressToFrameMap:s,samples:a}))}})}function b(n){let{fileName:s,addressToFrameMap:i,arrays:o,threadID:a,samples:c}=n;const l=new Map;c=c.filter(e=>e.threadID===a);const u=new e.StackListProfileBuilder((0,t.lastOf)(c).timestamp);function f(e,r){const n=i.get(e);if(n)r.push(n);else if(e in o)for(let t of o[e])f(t,r);else{const n={key:e,name:`0x${(0,t.zeroPad)(e.toString(16),16)}`};i.set(e,n),r.push(n)}}u.setName(`${s} - thread ${a}`);let h=null;for(let e of c){const r=(0,t.getOrInsert)(l,e.backtraceID,e=>{const t=[];return f(e,t),t.reverse(),t});if(null===h&&(u.appendSampleWithWeight([],e.timestamp),h=e.timestamp),e.timestamp<h)throw new Error("Timestamps out of order!");u.appendSampleWithWeight(r,e.timestamp-h),h=e.timestamp}return u.setValueFormatter(new r.TimeFormatter("nanoseconds")),u.build()}function y(e){return T(I(new Uint8Array(e)),(e,t)=>{switch(e){case"NSTextStorage":case"NSParagraphStyle":case"NSFont":return null;case"PFTSymbolData":{const e=Object.create(null);e.symbolName=t.$0,e.sourcePath=t.$1,e.addressToLine=new Map;for(let r=3;;r+=2){const n=t["$"+r],s=t["$"+(r+1)];if(null==n||null==s)break;e.addressToLine.set(n,s)}return e}case"PFTOwnerData":{const e=Object.create(null);return e.ownerName=t.$0,e.ownerPath=t.$1,e}case"PFTPersistentSymbols":{const e=Object.create(null),r=t.$4;e.threadNames=t.$3,e.symbols=[];for(let n=1;n<r;n++)e.symbols.push(t["$"+(4+n)]);return e}case"XRRunListData":{const e=Object.create(null);return e.runNumbers=t.$0,e.runData=t.$1,e}case"XRIntKeyedDictionary":{const e=new Map,r=t.$0;for(let n=0;n<r;n++){const r=t["$"+(1+2*n)],s=t["$"+(2*n+1+1)];e.set(r,s)}return e}case"XRCore":{const e=Object.create(null);return e.number=t.$0,e.name=t.$1,e}}return t})}function v(e){let t=String.fromCharCode.apply(String,Array.from(e));return"\0"===t.slice(-1)&&(t=t.slice(0,-1)),decodeURIComponent(escape(t))}function U(e){return e instanceof Array}function S(e){return null!==e&&"object"==typeof e&&null===Object.getPrototypeOf(e)}function N(e,t){return t instanceof x?e[t.index]:t}function T(e,t=(e=>e)){if(1e5!==e.$version||"NSKeyedArchiver"!==e.$archiver||!S(e.$top)||!U(e.$objects))throw new Error("Invalid keyed archive");"$null"===e.$objects[0]&&(e.$objects[0]=null);for(let n=0;n<e.$objects.length;n++)e.$objects[n]=$(e.$objects,e.$objects[n],t);let r=t=>{if(t instanceof x)return e.$objects[t.index];if(U(t))for(let e=0;e<t.length;e++)t[e]=r(t[e]);else if(S(t))for(let e in t)t[e]=r(t[e]);else if(t instanceof Map){const e=new Map(t);t.clear();for(let[n,s]of e.entries())t.set(r(n),r(s))}return t};for(let n=0;n<e.$objects.length;n++)r(e.$objects[n]);return r(e.$top)}function $(e,t,r=(e=>e)){if(S(t)&&t.$class){let n=N(e,t.$class).$classname;switch(n){case"NSDecimalNumberPlaceholder":{let e=t["NS.length"],r=t["NS.exponent"],n=t["NS.mantissa.bo"],s=t["NS.negative"],i=new Uint16Array(new Uint8Array(t["NS.mantissa"]).buffer),o=0;for(let t=0;t<e;t++){let e=i[t];1!==n&&(e=(65280&e)>>8|(255&e)<<8),o+=e*Math.pow(65536,t)}return o*=Math.pow(10,r),s?-o:o}case"NSData":case"NSMutableData":return t["NS.bytes"]||t["NS.data"];case"NSString":case"NSMutableString":return t["NS.string"]?t["NS.string"]:t["NS.bytes"]?v(t["NS.bytes"]):(console.warn(`Unexpected ${n} format: `,t),null);case"NSArray":case"NSMutableArray":if("NS.objects"in t)return t["NS.objects"];let e=[];for(;;){let r="NS.object."+e.length;if(!(r in t))break;e.push(t[r])}return e;case"_NSKeyedCoderOldStyleArray":{const e=t["NS.count"];let r=[];for(let n=0;n<e;n++){const e=t["$"+n];r.push(e)}return r}case"NSDictionary":case"NSMutableDictionary":let s=new Map;if("NS.keys"in t&&"NS.objects"in t)for(let r=0;r<t["NS.keys"].length;r++)s.set(t["NS.keys"][r],t["NS.objects"][r]);else for(;;){let e="NS.key."+s.size,r="NS.object."+s.size;if(!(e in t&&r in t))break;s.set(t[e],t[r])}return s;default:const i=r(n,t);if(i!==t)return i}}return t}class x{constructor(e){this.index=e}}function I(e){for(let t=0;t<8;t++)if(e[t]!=="bplist00".charCodeAt(t))throw new Error("File is not a binary plist");return new M(new DataView(e.buffer,e.byteOffset,e.byteLength)).parseRoot()}exports.UID=x;class M{constructor(e){this.view=e,this.referenceSize=0,this.objects=[],this.offsetTable=[]}parseRoot(){let e=this.view.byteLength-32,t=this.view.getUint8(e+6);this.referenceSize=this.view.getUint8(e+7);let r=this.view.getUint32(e+12,!1),n=this.view.getUint32(e+20,!1),s=this.view.getUint32(e+28,!1);for(let i=0;i<r;i++)this.offsetTable.push(this.parseInteger(s,t)),s+=t;return this.parseObject(this.offsetTable[n])}parseLengthAndOffset(e,t){if(15!==t)return{length:t,offset:0};let r=this.view.getUint8(e++);if(16!=(240&r))throw new Error("Unexpected non-integer length at offset "+e);let n=1<<(15&r);return{length:this.parseInteger(e,n),offset:n+1}}parseSingleton(e,t){if(0===t)return null;if(8===t)return!1;if(9===t)return!0;throw new Error("Unexpected extra value "+t+" at offset "+e)}parseInteger(e,t){if(1===t)return this.view.getUint8(e);if(2===t)return this.view.getUint16(e,!1);if(4===t)return this.view.getUint32(e,!1);if(8===t)return Math.pow(2,32)*this.view.getUint32(e+0,!1)+Math.pow(2,0)*this.view.getUint32(e+4,!1);if(16===t)return Math.pow(2,96)*this.view.getUint32(e+0,!1)+Math.pow(2,64)*this.view.getUint32(e+4,!1)+Math.pow(2,32)*this.view.getUint32(e+8,!1)+Math.pow(2,0)*this.view.getUint32(e+12,!1);throw new Error("Unexpected integer of size "+t+" at offset "+e)}parseFloat(e,t){if(4===t)return this.view.getFloat32(e,!1);if(8===t)return this.view.getFloat64(e,!1);throw new Error("Unexpected float of size "+t+" at offset "+e)}parseDate(e,t){if(8!==t)throw new Error("Unexpected date of size "+t+" at offset "+e);let r=this.view.getFloat64(e,!1);return new Date(9783072e5+1e3*r)}parseData(e,t){let r=this.parseLengthAndOffset(e,t);return new Uint8Array(this.view.buffer,e+r.offset,r.length)}parseStringASCII(e,t){let r=this.parseLengthAndOffset(e,t),n="";e+=r.offset;for(let s=0;s<r.length;s++)n+=String.fromCharCode(this.view.getUint8(e++));return n}parseStringUTF16(e,t){let r=this.parseLengthAndOffset(e,t),n="";e+=r.offset;for(let s=0;s<r.length;s++)n+=String.fromCharCode(this.view.getUint16(e,!1)),e+=2;return n}parseUID(e,t){return new x(this.parseInteger(e,t))}parseArray(e,t){let r=this.parseLengthAndOffset(e,t),n=[],s=this.referenceSize;e+=r.offset;for(let i=0;i<r.length;i++)n.push(this.parseObject(this.offsetTable[this.parseInteger(e,s)])),e+=s;return n}parseDictionary(e,t){let r=this.parseLengthAndOffset(e,t),n=Object.create(null),s=this.referenceSize,i=e+r.offset,o=i+r.length*s;for(let a=0;a<r.length;a++){let e=this.parseObject(this.offsetTable[this.parseInteger(i,s)]),t=this.parseObject(this.offsetTable[this.parseInteger(o,s)]);if("string"!=typeof e)throw new Error("Unexpected non-string key at offset "+i);n[e]=t,i+=s,o+=s}return n}parseObject(e){let t=this.view.getUint8(e++),r=15&t;switch(t>>4){case 0:return this.parseSingleton(e,r);case 1:return this.parseInteger(e,1<<r);case 2:return this.parseFloat(e,1<<r);case 3:return this.parseDate(e,1<<r);case 4:return this.parseData(e,r);case 5:return this.parseStringASCII(e,r);case 6:return this.parseStringUTF16(e,r);case 8:return this.parseUID(e,r+1);case 10:return this.parseArray(e,r);case 13:return this.parseDictionary(e,r)}throw new Error("Unexpected marker "+t+" at offset "+--e)}}
43
45
  },{"../lib/profile":"YG8z","../lib/utils":"ucYa","../lib/value-formatters":"LsM4","./utils":"QTYz"}],"flbo":[function(require,module,exports) {
44
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.importFromBGFlameGraph=t;var e=require("../lib/profile");function r(e){const r=[];return e.replace(/^(.*) (\d+)$/gm,(e,t,i)=>(r.push({stack:t.split(";").map(e=>({key:e,name:e})),duration:parseInt(i,10)}),e)),r}function t(t){const i=r(t),n=i.reduce((e,r)=>e+r.duration,0),o=new e.StackListProfileBuilder(n);if(0===i.length)return null;for(let e of i)o.appendSampleWithWeight(e.stack,e.duration);return o.build()}
46
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.importFromBGFlameGraph=r;var e=require("../lib/profile");function t(e){const t=[];for(const r of e.splitLines()){const e=/^(.*) (\d+)$/gm.exec(r);if(!e)continue;const n=e[1],i=e[2];t.push({stack:n.split(";").map(e=>({key:e,name:e})),duration:parseInt(i,10)})}return t}function r(r){const n=t(r),i=n.reduce((e,t)=>e+t.duration,0),o=new e.StackListProfileBuilder(i);if(0===n.length)return null;for(let e of n)o.appendSampleWithWeight(e.stack,e.duration);return o.build()}
45
47
  },{"../lib/profile":"YG8z"}],"uNW1":[function(require,module,exports) {
46
48
  "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.importFromFirefox=l;var e=require("../lib/profile"),t=require("../lib/utils"),r=require("../lib/value-formatters");function l(l){const n=l.profile,s=1===n.threads.length?n.threads[0]:n.threads.filter(e=>"GeckoMain"===e.name)[0],a=new Map;function o(e){let r=e[0];const l=[];for(;null!=r;){const e=s.stackTable.data[r],[t,n]=e;l.push(n),r=t}return l.reverse(),l.map(e=>{const r=s.frameTable.data[e],l=s.stringTable[r[0]],n=/(.*)\s+\((.*?)(?::(\d+))?(?::(\d+))?\)$/.exec(l);return n?n[2].startsWith("resource:")||"self-hosted"===n[2]||n[2].startsWith("self-hosted:")?null:(0,t.getOrInsert)(a,l,()=>({key:l,name:n[1],file:n[2],line:n[3]?parseInt(n[3]):void 0,col:n[4]?parseInt(n[4])+1:void 0})):null}).filter(e=>null!=e)}const i=new e.CallTreeProfileBuilder(l.duration);let u=[];for(let e of s.samples.data){const t=o(e),r=e[1];let l=-1;for(let e=0;e<Math.min(t.length,u.length)&&u[e]===t[e];e++)l=e;for(let e=u.length-1;e>l;e--)i.leaveFrame(u[e],r);for(let e=l+1;e<t.length;e++)i.enterFrame(t[e],r);u=t}return i.setValueFormatter(new r.TimeFormatter("milliseconds")),i.build()}
47
49
  },{"../lib/profile":"YG8z","../lib/utils":"ucYa","../lib/value-formatters":"LsM4"}],"QV03":[function(require,module,exports) {
48
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.importFromV8ProfLog=n;var e=require("../lib/profile"),t=require("../lib/utils"),r=require("../lib/value-formatters");function a(e,t){if(!e||!e.type)return{key:"(unknown type)",name:"(unknown type)"};let r=e.name;switch(e.type){case"CPP":{const e=r.match(/[tT] ([^(<]*)/);e&&(r=`(c++) ${e[1]}`);break}case"SHARED_LIB":r="(LIB) "+r;break;case"JS":{const e=r.match(/([a-zA-Z0-9\._\-$]*) ([a-zA-Z0-9\.\-_\/$]*):(\d+):(\d+)/);if(e)return{key:r,name:e[1].length>0?e[1]:"(anonymous)",file:e[2].length>0?e[2]:"(unknown file)",line:parseInt(e[3],10),col:parseInt(e[4],10)};break}case"CODE":switch(e.kind){case"LoadIC":case"StoreIC":case"KeyedStoreIC":case"KeyedLoadIC":case"LoadGlobalIC":case"Handler":r="(IC) "+r;break;case"BytecodeHandler":r="(bytecode) ~"+r;break;case"Stub":r="(stub) "+r;break;case"Builtin":r="(builtin) "+r;break;case"RegExp":r="(regexp) "+r}break;default:r=`(${e.type}) ${r}`}return{key:r,name:r}}function n(n){const s=new e.StackListProfileBuilder,o=new Map;let c=0;(0,t.sortBy)(n.ticks,e=>e.tm);for(let e of n.ticks){const r=[];for(let s=e.s.length-2;s>=0;s-=2){const c=e.s[s];-1!==c&&(c>n.code.length?r.push({key:c,name:`0x${c.toString(16)}`}):r.push((i=c,(0,t.getOrInsert)(o,i,e=>a(n.code[e],n)))))}s.appendSampleWithWeight(r,e.tm-c),c=e.tm}var i;return s.setValueFormatter(new r.TimeFormatter("microseconds")),s.build()}
50
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.importFromV8ProfLog=n;var e=require("../lib/profile"),t=require("../lib/utils"),r=require("../lib/value-formatters");function a(e,t){if(!e||!e.type)return{key:"(unknown type)",name:"(unknown type)"};let r=e.name;switch(e.type){case"CPP":{const e=r.match(/[tT] ([^(<]*)/);e&&(r=`(c++) ${e[1]}`);break}case"SHARED_LIB":r="(LIB) "+r;break;case"JS":{const e=r.match(/([a-zA-Z0-9\._\-$]*) ([a-zA-Z0-9\.\-_\/$]*):(\d+):(\d+)/);if(e){const t=e[2],a=parseInt(e[3],10),n=parseInt(e[4],10);return{key:r,name:e[1].length>0?e[1]:t?`(anonymous ${t.split("/").pop()}:${a})`:"(anonymous)",file:t.length>0?t:"(unknown file)",line:a,col:n}}break}case"CODE":switch(e.kind){case"LoadIC":case"StoreIC":case"KeyedStoreIC":case"KeyedLoadIC":case"LoadGlobalIC":case"Handler":r="(IC) "+r;break;case"BytecodeHandler":r="(bytecode) ~"+r;break;case"Stub":r="(stub) "+r;break;case"Builtin":r="(builtin) "+r;break;case"RegExp":r="(regexp) "+r}break;default:r=`(${e.type}) ${r}`}return{key:r,name:r}}function n(n){const o=new e.StackListProfileBuilder,s=new Map;let c=0;(0,t.sortBy)(n.ticks,e=>e.tm);for(let e of n.ticks){const r=[];for(let o=e.s.length-2;o>=0;o-=2){const c=e.s[o];-1!==c&&(c>n.code.length?r.push({key:c,name:`0x${c.toString(16)}`}):r.push((i=c,(0,t.getOrInsert)(s,i,e=>a(n.code[e],n)))))}o.appendSampleWithWeight(r,e.tm-c),c=e.tm}var i;return o.setValueFormatter(new r.TimeFormatter("microseconds")),o.build()}
49
51
  },{"../lib/profile":"YG8z","../lib/utils":"ucYa","../lib/value-formatters":"LsM4"}],"f2sa":[function(require,module,exports) {
50
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.importFromLinuxPerf=r;var e=require("../lib/profile"),t=require("../lib/utils"),n=require("../lib/value-formatters");function s(e){const t=e.split("\n").filter(e=>!/^\s*#/.exec(e)),n={command:null,processID:null,threadID:null,time:null,eventType:"",stack:[]},s=t.shift();if(!s)return null;const r=/^(\S.+?)\s+(\d+)(?:\/?(\d+))?\s+/.exec(s);if(!r)return null;n.command=r[1],r[3]?(n.processID=parseInt(r[2],10),n.threadID=parseInt(r[3],10)):n.threadID=parseInt(r[2],10);const l=/\s+(\d+\.\d+):\s+/.exec(s);l&&(n.time=parseFloat(l[1]));const i=/(\S+):\s*$/.exec(s);i&&(n.eventType=i[1]);for(let o of t){const e=/^\s*(\w+)\s*(.+) \((\S*)\)/.exec(o);if(!e)continue;let[,t,s,r]=e;s=s.replace(/\+0x[\da-f]+$/,""),n.stack.push({address:`0x${t}`,symbolName:s,file:r})}return n.stack.reverse(),n}function r(r){const l=new Map;let i=null;const o=r.split("\n\n").map(s);for(let s of o){if(null==s)continue;if(null!=i&&i!=s.eventType)continue;if(null==s.time)continue;i=s.eventType;let r=[];s.command&&r.push(s.command),s.processID&&r.push(`pid: ${s.processID}`),s.threadID&&r.push(`tid: ${s.threadID}`);const o=r.join(" ");(0,t.getOrInsert)(l,o,()=>{const t=new e.StackListProfileBuilder;return t.setName(o),t.setValueFormatter(new n.TimeFormatter("seconds")),t}).appendSampleWithTimestamp(s.stack.map(({symbolName:e,file:t})=>({key:`${e} (${t})`,name:"[unknown]"===e?`??? (${t})`:e,file:t})),s.time)}return 0===l.size?null:{name:1===l.size?Array.from(l.keys())[0]:"",indexToView:0,profiles:Array.from((0,t.itMap)(l.values(),e=>e.build()))}}
52
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.importFromLinuxPerf=l;var e=require("../lib/profile"),t=require("../lib/utils"),n=require("../lib/value-formatters");function s(e){const t=e.split("\n").filter(e=>!/^\s*#/.exec(e)),n={command:null,processID:null,threadID:null,time:null,eventType:"",stack:[]},s=t.shift();if(!s)return null;const r=/^(\S.+?)\s+(\d+)(?:\/?(\d+))?\s+/.exec(s);if(!r)return null;n.command=r[1],r[3]?(n.processID=parseInt(r[2],10),n.threadID=parseInt(r[3],10)):n.threadID=parseInt(r[2],10);const l=/\s+(\d+\.\d+):\s+/.exec(s);l&&(n.time=parseFloat(l[1]));const i=/(\S+):\s*$/.exec(s);i&&(n.eventType=i[1]);for(let o of t){const e=/^\s*(\w+)\s*(.+) \((\S*)\)/.exec(o);if(!e)continue;let[,t,s,r]=e;s=s.replace(/\+0x[\da-f]+$/,""),n.stack.push({address:`0x${t}`,symbolName:s,file:r})}return n.stack.reverse(),n}function r(e){const t=[];let n="";for(let s of e.splitLines())""===s?(n.length>0&&t.push(n),n=s):(n.length>0&&(n+="\n"),n+=s);return n.length>0&&t.push(n),t}function l(l){const i=new Map;let o=null;const a=r(l).map(s);for(let s of a){if(null==s)continue;if(null!=o&&o!=s.eventType)continue;if(null==s.time)continue;o=s.eventType;let r=[];s.command&&r.push(s.command),s.processID&&r.push(`pid: ${s.processID}`),s.threadID&&r.push(`tid: ${s.threadID}`);const l=r.join(" ");(0,t.getOrInsert)(i,l,()=>{const t=new e.StackListProfileBuilder;return t.setName(l),t.setValueFormatter(new n.TimeFormatter("seconds")),t}).appendSampleWithTimestamp(s.stack.map(({symbolName:e,file:t})=>({key:`${e} (${t})`,name:"[unknown]"===e?`??? (${t})`:e,file:t})),s.time)}return 0===i.size?null:{name:1===i.size?Array.from(i.keys())[0]:"",indexToView:0,profiles:Array.from((0,t.itMap)(i.values(),e=>e.build()))}}
51
53
  },{"../lib/profile":"YG8z","../lib/utils":"ucYa","../lib/value-formatters":"LsM4"}],"jm73":[function(require,module,exports) {
52
54
  "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.importFromHaskell=l;var e=require("../lib/profile"),r=require("../lib/value-formatters");function t(e,r,l,o,i){if(0===e.ticks&&0===e.entries&&0===e.alloc&&0===e.children.length)return r;let a=r,s=o.get(e.id);l.enterFrame(s,a);for(let n of e.children)a=t(n,a,l,o,i);return a+=i(e),l.leaveFrame(s,a),a}function l(l){const o=new Map;for(let e of l.cost_centres){const r={key:e.id,name:`${e.module}.${e.label}`};e.src_loc.startsWith("<")||(r.file=e.src_loc),o.set(e.id,r)}const i=new e.CallTreeProfileBuilder(l.total_ticks);t(l.profile,0,i,o,e=>e.ticks),i.setValueFormatter(new r.TimeFormatter("milliseconds")),i.setName(`${l.program} time`);const a=new e.CallTreeProfileBuilder(l.total_ticks);return t(l.profile,0,a,o,e=>e.alloc),a.setValueFormatter(new r.ByteFormatter),a.setName(`${l.program} allocation`),{name:l.program,indexToView:0,profiles:[i.build(),a.build()]}}
53
55
  },{"../lib/profile":"YG8z","../lib/value-formatters":"LsM4"}],"jP3w":[function(require,module,exports) {
54
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.importFromSafari=i;var e=require("../lib/profile"),r=require("../lib/value-formatters");function t(e){return e.map(({name:e,url:r,line:t,column:i})=>({key:`${e}:${r}:${t}:${i}`,file:r,line:t,col:i,name:e||"(anonymous)"})).reverse()}function i(i){1!==i.version&&console.warn(`Unknown Safari profile version ${i.version}... Might be incompatible.`);const{recording:n}=i,{sampleStackTraces:a,sampleDurations:o}=n,s=a.length;if(s<1)return console.warn("Empty profile"),null;const l=a[s-1].timestamp-a[0].timestamp+o[0],m=new e.StackListProfileBuilder(l);let p=Number.MAX_VALUE;return a.forEach((e,r)=>{const i=e.timestamp,n=o[r],a=i-n-p;a>.002&&m.appendSampleWithWeight([],a),m.appendSampleWithWeight(t(e.stackFrames),n),p=i}),m.setValueFormatter(new r.TimeFormatter("seconds")),m.setName(n.displayName),m.build()}
56
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.importFromSafari=i;var e=require("../lib/profile"),r=require("../lib/value-formatters");function t(e){return e.map(({name:e,url:r,line:t,column:i})=>({key:`${e}:${r}:${t}:${i}`,file:r,line:t,col:i,name:e||(r?`(anonymous ${r.split("/").pop()}:${t})`:"(anonymous)")})).reverse()}function i(i){1!==i.version&&console.warn(`Unknown Safari profile version ${i.version}... Might be incompatible.`);const{recording:n}=i,{sampleStackTraces:a,sampleDurations:o}=n,s=a.length;if(s<1)return console.warn("Empty profile"),null;const l=a[s-1].timestamp-a[0].timestamp+o[0],m=new e.StackListProfileBuilder(l);let p=Number.MAX_VALUE;return a.forEach((e,r)=>{const i=e.timestamp,n=o[r],a=i-n-p;a>.002&&m.appendSampleWithWeight([],a),m.appendSampleWithWeight(t(e.stackFrames),n),p=i}),m.setValueFormatter(new r.TimeFormatter("seconds")),m.setName(n.displayName),m.build()}
55
57
  },{"../lib/profile":"YG8z","../lib/value-formatters":"LsM4"}],"oU4k":[function(require,module,exports) {
56
58
  "use strict";function n(n,e){for(var r=new Array(arguments.length-1),t=0,l=2,o=!0;l<arguments.length;)r[t++]=arguments[l++];return new Promise(function(l,u){r[t]=function(n){if(o)if(o=!1,n)u(n);else{for(var e=new Array(arguments.length-1),r=0;r<e.length;)e[r++]=arguments[r];l.apply(null,e)}};try{n.apply(e||null,r)}catch(a){o&&(o=!1,u(a))}})}module.exports=n;
57
59
  },{}],"SASd":[function(require,module,exports) {
@@ -106,12 +108,12 @@ var e=arguments[3],r=require("buffer").Buffer,t=exports;function n(e,r,t){for(va
106
108
  },{"protobufjs/minimal":"Myh2"}],"VmHy":[function(require,module,exports) {
107
109
  "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.importAsPprofProfile=r;var e=require("./profile.proto.js"),n=require("../lib/profile"),t=require("../lib/utils"),l=require("../lib/value-formatters");function r(r){if(0===r.byteLength)return null;let o;try{o=e.perftools.profiles.Profile.decode(new Uint8Array(r))}catch(b){return null}function i(e){return"number"==typeof e?e:e.low}function u(e){return o.stringTable[i(e)]||null}const s=new Map;function a(e){const{name:n,filename:t,startLine:l}=e,r=null!=n&&u(n)||"(unknown)",o=null!=t?u(t):null,i=null!=l?+l:null,s={key:`${r}:${o}:${i}`,name:r};return null!=o&&(s.file=o),null!=i&&(s.line=i),s}for(let e of o.function)if(e.id){const n=a(e);null!=n&&s.set(i(e.id),n)}function c(e){const{line:n}=e;if(null==n)return null;const l=(0,t.lastOf)(n);return null==l?null:l.functionId&&s.get(i(l.functionId))||null}const f=new Map;for(let e of o.location)if(null!=e.id){const n=c(e);n&&f.set(i(e.id),n)}const p=o.sampleType.map(e=>({type:e.type&&u(e.type)||"samples",unit:e.unit&&u(e.unit)||"count"})),d=o.defaultSampleType?+o.defaultSampleType:p.length-1,m=p[d],y=new n.StackListProfileBuilder;switch(m.unit){case"nanoseconds":case"microseconds":case"milliseconds":case"seconds":y.setValueFormatter(new l.TimeFormatter(m.unit));break;case"bytes":y.setValueFormatter(new l.ByteFormatter)}for(let e of o.sample){const n=e.locationId?e.locationId.map(e=>f.get(i(e))):[];n.reverse();const t=e.value[d];y.appendSampleWithWeight(n.filter(e=>null!=e),+t)}return y.build()}
108
110
  },{"./profile.proto.js":"YdJi","../lib/profile":"YG8z","../lib/utils":"ucYa","../lib/value-formatters":"LsM4"}],"bNW7":[function(require,module,exports) {
109
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.importFromChromeHeapProfile=o;var e=require("../lib/profile"),r=require("../lib/utils"),t=require("../lib/value-formatters");const n=new Map;function i(e){return(0,r.getOrInsert)(n,e,e=>{const r=e.functionName||"(anonymous)",t=e.url,n=e.lineNumber,i=e.columnNumber;return{key:`${r}:${t}:${n}:${i}`,name:r,file:t,line:n,col:i}})}function o(r){const n=new Map;let o=0;const l=(e,r)=>{e.id=o++,n.set(e.id,e),r&&(e.parent=r.id),e.children.forEach(r=>l(r,e))};l(r.head);const u=e=>{if(0===e.children.length)return e.selfSize||0;const r=e.children.reduce((e,r)=>e+=u(r),e.selfSize);return e.totalSize=r,r},a=u(r.head),s=[];for(let e of n.values()){let r=[];for(r.push(e);void 0!==e.parent;){const t=n.get(e.parent);if(void 0===t)break;r.unshift(t),e=t}s.push(r)}const c=new e.StackListProfileBuilder(a);for(let e of s){const r=e[e.length-1];c.appendSampleWithWeight(e.map(e=>i(e.callFrame)),r.selfSize)}return c.setValueFormatter(new t.ByteFormatter),c.build()}
111
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.importFromChromeHeapProfile=i;var e=require("../lib/profile"),t=require("../lib/utils"),r=require("../lib/value-formatters");const n=new Map;function o(e){return(0,t.getOrInsert)(n,e,e=>{const t=e.url,r=e.lineNumber,n=e.columnNumber,o=e.functionName||(t?`(anonymous ${t.split("/").pop()}:${r})`:"(anonymous)");return{key:`${o}:${t}:${r}:${n}`,name:o,file:t,line:r,col:n}})}function i(t){const n=new Map;let i=0;const l=(e,t)=>{e.id=i++,n.set(e.id,e),t&&(e.parent=t.id),e.children.forEach(t=>l(t,e))};l(t.head);const s=e=>{if(0===e.children.length)return e.selfSize||0;const t=e.children.reduce((e,t)=>e+=s(t),e.selfSize);return e.totalSize=t,t},u=s(t.head),a=[];for(let e of n.values()){let t=[];for(t.push(e);void 0!==e.parent;){const r=n.get(e.parent);if(void 0===r)break;t.unshift(r),e=r}a.push(t)}const c=new e.StackListProfileBuilder(u);for(let e of a){const t=e[e.length-1];c.appendSampleWithWeight(e.map(e=>o(e.callFrame)),t.selfSize)}return c.setValueFormatter(new r.ByteFormatter),c.build()}
110
112
  },{"../lib/profile":"YG8z","../lib/utils":"ucYa","../lib/value-formatters":"LsM4"}],"KFvE":[function(require,module,exports) {
111
113
  "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.isTraceEventFormatted=m,exports.importTraceEvents=g;var e=require("../lib/utils"),t=require("../lib/profile"),n=require("../lib/value-formatters");function r(t,n){return`${(0,e.zeroPad)(""+t,10)}:${(0,e.zeroPad)(""+n,10)}`}function s(t){const n=new Map;for(let s of t){(0,e.getOrInsert)(n,r(s.pid,s.tid),()=>[]).push(s)}return n}function o(e,t){if(0===e.length&&0===t.length)throw new Error("This method should not be given both queues empty");if(0===t.length)return"B";if(0===e.length)return"E";const n=e[0],r=t[0],s=n.ts,o=r.ts;return s<o?"B":o<s?"E":n.name===r.name?"B":"E"}function a(e){const t=[],n=[];if(e.length>0){let t=Number.MAX_SAFE_INTEGER;for(let n of e)t=Math.min(t,n.ts);for(let n of e)n.ts-=t}const r=[];for(let a of e)switch(a.ph){case"B":t.push(a);break;case"E":n.push(a);break;case"X":r.push(a);break;default:return a}function s(e){var t,n;return null!==(n=null!==(t=e.dur)&&void 0!==t?t:e.tdur)&&void 0!==n?n:0}r.sort((e,t)=>{if(e.ts<t.ts)return-1;if(e.ts>t.ts)return 1;const n=s(e),r=s(t);return n>r?-1:n<r?1:0});for(let a of r){const e=s(a);t.push(Object.assign(Object.assign({},a),{ph:"B"})),n.push(Object.assign(Object.assign({},a),{ph:"E",ts:a.ts+e}))}function o(e,t){return e.ts<t.ts?-1:e.ts>t.ts?1:0}return t.sort(o),n.sort(o),[t,n]}function i(e){const t=[];for(let n of e)switch(n.ph){case"B":case"E":case"X":t.push(n)}return t}function u(e){const t=new Map;for(let n of e)"M"===n.ph&&"process_name"===n.name&&n.args&&n.args.name&&t.set(n.pid,n.args.name);return t}function c(e){const t=new Map;for(let n of e)"M"===n.ph&&"thread_name"===n.name&&n.args&&n.args.name&&t.set(r(n.pid,n.tid),n.args.name);return t}function f(e){let t=`${e.name||"(unnamed)"}`;return e.args&&(t+=` ${JSON.stringify(e.args)}`),t}function l(e){const t=f(e);return{name:t,key:t}}function h(f){const h=s(i(f)),d=u(f),p=c(f),m=[];return h.forEach(s=>{if(0===s.length)return;const{pid:i,tid:u}=s[0],c=new t.CallTreeProfileBuilder;c.setValueFormatter(new n.TimeFormatter("microseconds"));const f=d.get(i),h=p.get(r(i,u));null!=f&&null!=h?c.setName(`${f} (pid ${i}), ${h} (tid ${u})`):null!=f?c.setName(`${f} (pid ${i}, tid ${u})`):null!=h?c.setName(`${h} (pid ${i}, tid ${u})`):c.setName(`pid ${i}, tid ${u}`);const[g,$]=a(s),k=[],b=e=>{k.push(e),c.enterFrame(l(e),e.ts)},w=t=>{const n=(0,e.lastOf)(k);if(null==n)return void console.warn(`Tried to end frame "${l(t).key}", but the stack was empty. Doing nothing instead.`);const r=l(t),s=l(n);t.name===n.name?(r.key!==s.key&&console.warn(`ts=${t.ts}: Tried to end "${r.key}" when "${s.key}" was on the top of the stack. Ending ${s.key} instead.`),k.pop(),c.leaveFrame(s,t.ts)):console.warn(`ts=${t.ts}: Tried to end "${r.key}" when "${s.key}" was on the top of the stack. Doing nothing instead.`)};for(;g.length>0||$.length>0;){const t=o(g,$);switch(t){case"B":b(g.shift());break;case"E":{const t=(0,e.lastOf)(k);if(null!=t){const e=l(t);let n=!1;for(let t=1;t<$.length;t++){const r=$[t];if(r.ts>$[0].ts)break;const s=l(r);if(e.key===s.key){const e=$[0];$[0]=$[t],$[t]=e,n=!0;break}}if(!n)for(let r=1;r<$.length;r++){const e=$[r];if(e.ts>$[0].ts)break;if(e.name===t.name){const e=$[0];$[0]=$[r],$[r]=e,n=!0;break}}}w($.shift());break}default:return t}}for(let e=k.length-1;e>=0;e--){const t=l(k[e]);console.warn(`Frame "${t.key}" was still open at end of profile. Closing automatically.`),c.leaveFrame(t,c.getTotalWeight())}m.push([r(i,u),c.build()])}),(0,e.sortBy)(m,e=>e[0]),{name:"",indexToView:0,profiles:m.map(e=>e[1])}}function d(e){if(!Array.isArray(e))return!1;if(0===e.length)return!1;for(let t of e){if(!("ph"in t))return!1;switch(t.ph){case"B":case"E":case"X":if(!("ts"in t))return!1}}return!0}function p(e){return"traceEvents"in e&&d(e.traceEvents)}function m(e){return p(e)||d(e)}function g(e){if(p(e))return h(e.traceEvents);if(d(e))return h(e);return e}
112
114
  },{"../lib/utils":"ucYa","../lib/profile":"YG8z","../lib/value-formatters":"LsM4"}],"TZYa":[function(require,module,exports) {
113
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.importFromCallgrind=r;var e=require("../lib/profile"),t=require("../lib/utils"),i=require("../lib/value-formatters");class s{constructor(e,i){this.fileName=e,this.fieldName=i,this.frameSet=new t.KeyedSet,this.totalWeights=new Map,this.childrenTotalWeights=new Map}getOrInsertFrame(t){return e.Frame.getOrInsert(this.frameSet,t)}addToTotalWeight(e,t){this.totalWeights.has(e)?this.totalWeights.set(e,this.totalWeights.get(e)+t):this.totalWeights.set(e,t)}addSelfWeight(e,t){this.addToTotalWeight(this.getOrInsertFrame(e),t)}addChildWithTotalWeight(e,i,s){const n=this.getOrInsertFrame(e),r=this.getOrInsertFrame(i),a=(0,t.getOrInsert)(this.childrenTotalWeights,n,e=>new Map);a.has(r)?a.set(r,a.get(r)+s):a.set(r,s),this.addToTotalWeight(n,s)}toProfile(){const s=new Map;for(let[e,t]of this.totalWeights)s.set(e,t);for(let[e,i]of this.childrenTotalWeights)for(let[n,r]of i)s.set(n,(0,t.getOrElse)(s,n,()=>r)-r);let n=0;for(let[e,t]of s)n+=t;const r=new e.CallTreeProfileBuilder;let a=1;"Time_(10ns)"===this.fieldName?(r.setName(`${this.fileName} -- Time`),a=10,r.setValueFormatter(new i.TimeFormatter("nanoseconds"))):"Memory_(bytes)"==this.fieldName?(r.setName(`${this.fileName} -- Memory`),r.setValueFormatter(new i.ByteFormatter)):r.setName(`${this.fileName} -- ${this.fieldName}`);let l=0;const o=new Set,h=(e,i)=>{if(o.has(e))return;if(i<1e-4*n)return;const s=(0,t.getOrElse)(this.totalWeights,e,()=>0);if(0===s)return;const m=i/s;let c=s;r.enterFrame(e,l*a),o.add(e);for(let[t,n]of this.childrenTotalWeights.get(e)||[]){c-=n,h(t,n*m)}o.delete(e),l+=c*m,r.leaveFrame(e,l*a)};for(let[e,t]of s)t<=0||h(e,t);return r.build()}}class n{constructor(e,t){this.importedFileName=t,this.callGraphs=null,this.eventsLine=null,this.filename=null,this.functionName=null,this.calleeFilename=null,this.calleeFunctionName=null,this.savedFileNames={},this.savedFunctionNames={},this.lines=e.split("\n"),this.lineNum=0}parse(){for(;this.lineNum<this.lines.length;){const e=this.lines[this.lineNum++];if(!/^\s*#/.exec(e)&&!(/^\s*$/.exec(e)||this.parseHeaderLine(e)||this.parseAssignmentLine(e)||this.parseCostLine(e,"self")))throw new Error(`Unrecognized line "${e}" on line ${this.lineNum}`)}return this.callGraphs?{name:this.importedFileName,indexToView:0,profiles:this.callGraphs.map(e=>e.toProfile())}:null}frameInfo(){const e=this.filename||"(unknown)",t=this.functionName||"(unknown)";return{key:`${e}:${t}`,name:t,file:e}}calleeFrameInfo(){const e=this.calleeFilename||"(unknown)",t=this.calleeFunctionName||"(unknown)";return{key:`${e}:${t}`,name:t,file:e}}parseHeaderLine(e){const t=/^\s*(\w+):\s*(.*)+$/.exec(e);if(!t)return!1;if("events"!==t[1])return!0;const i=t[2].split(" ");if(null!=this.callGraphs)throw new Error(`Duplicate "events: " lines specified. First was "${this.eventsLine}", now received "${e}" on ${this.lineNum}.`);return this.callGraphs=i.map(e=>new s(this.importedFileName,e)),!0}parseAssignmentLine(e){const t=/^(\w+)=\s*(.*)$/.exec(e);if(!t)return!1;const i=t[1],s=t[2];switch(i){case"fe":case"fi":case"fl":this.filename=this.parseNameWithCompression(s,this.savedFileNames),this.calleeFilename=this.filename;break;case"fn":this.functionName=this.parseNameWithCompression(s,this.savedFunctionNames);break;case"cfi":case"cfl":this.calleeFilename=this.parseNameWithCompression(s,this.savedFileNames);break;case"cfn":this.calleeFunctionName=this.parseNameWithCompression(s,this.savedFunctionNames);break;case"calls":this.parseCostLine(this.lines[this.lineNum++],"child");break;default:console.log(`Ignoring assignment to unrecognized key "${e}" on line ${this.lineNum}`)}return!0}parseNameWithCompression(e,t){{const i=/^\((\d+)\)\s*(.+)$/.exec(e);if(i){const e=i[1],s=i[2];if(e in t)throw new Error(`Redefinition of name with id: ${e}. Original value was "${t[e]}". Tried to redefine as "${s}" on line ${this.lineNum}.`);return t[e]=s,s}}{const i=/^\((\d+)\)$/.exec(e);if(i){const e=i[1];if(!(e in t))throw new Error(`Tried to use name with id ${e} on line ${this.lineNum} before it was defined.`);return t[e]}}return e}parseCostLine(e,t){const i=e.split(/\s+/),s=[];for(let n of i){const e=parseInt(n);if(isNaN(e))return!1;s.push(e)}if(0==s.length)return!1;if(!this.callGraphs)throw new Error(`Encountered a cost line on line ${this.lineNum} before event specification was provided.`);for(let n=0;n<this.callGraphs.length;n++)"self"===t?this.callGraphs[n].addSelfWeight(this.frameInfo(),s[1+n]):"child"===t&&this.callGraphs[n].addChildWithTotalWeight(this.frameInfo(),this.calleeFrameInfo(),s[1+n]||0);return!0}}function r(e,t){return new n(e,t).parse()}
115
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.importFromCallgrind=r;var e=require("../lib/profile"),t=require("../lib/utils"),i=require("../lib/value-formatters");class s{constructor(e,i){this.fileName=e,this.fieldName=i,this.frameSet=new t.KeyedSet,this.totalWeights=new Map,this.childrenTotalWeights=new Map}getOrInsertFrame(t){return e.Frame.getOrInsert(this.frameSet,t)}addToTotalWeight(e,t){this.totalWeights.has(e)?this.totalWeights.set(e,this.totalWeights.get(e)+t):this.totalWeights.set(e,t)}addSelfWeight(e,t){this.addToTotalWeight(this.getOrInsertFrame(e),t)}addChildWithTotalWeight(e,i,s){const n=this.getOrInsertFrame(e),r=this.getOrInsertFrame(i),a=(0,t.getOrInsert)(this.childrenTotalWeights,n,e=>new Map);a.has(r)?a.set(r,a.get(r)+s):a.set(r,s),this.addToTotalWeight(n,s)}toProfile(){const s=new Map;for(let[e,t]of this.totalWeights)s.set(e,t);for(let[e,i]of this.childrenTotalWeights)for(let[n,r]of i)s.set(n,(0,t.getOrElse)(s,n,()=>r)-r);let n=0;for(let[e,t]of s)n+=t;const r=new e.CallTreeProfileBuilder;let a=1;"Time_(10ns)"===this.fieldName?(r.setName(`${this.fileName} -- Time`),a=10,r.setValueFormatter(new i.TimeFormatter("nanoseconds"))):"Memory_(bytes)"==this.fieldName?(r.setName(`${this.fileName} -- Memory`),r.setValueFormatter(new i.ByteFormatter)):r.setName(`${this.fileName} -- ${this.fieldName}`);let l=0;const o=new Set,h=(e,i)=>{if(o.has(e))return;if(i<1e-4*n)return;const s=(0,t.getOrElse)(this.totalWeights,e,()=>0);if(0===s)return;const m=i/s;let c=s;r.enterFrame(e,l*a),o.add(e);for(let[t,n]of this.childrenTotalWeights.get(e)||[]){c-=n,h(t,n*m)}o.delete(e),l+=c*m,r.leaveFrame(e,l*a)};for(let[e,t]of s)t<=0||h(e,t);return r.build()}}class n{constructor(e,t){this.importedFileName=t,this.callGraphs=null,this.eventsLine=null,this.filename=null,this.functionName=null,this.calleeFilename=null,this.calleeFunctionName=null,this.savedFileNames={},this.savedFunctionNames={},this.lines=e.splitLines(),this.lineNum=0}parse(){for(;this.lineNum<this.lines.length;){const e=this.lines[this.lineNum++];if(!/^\s*#/.exec(e)&&!(/^\s*$/.exec(e)||this.parseHeaderLine(e)||this.parseAssignmentLine(e)||this.parseCostLine(e,"self")))throw new Error(`Unrecognized line "${e}" on line ${this.lineNum}`)}return this.callGraphs?{name:this.importedFileName,indexToView:0,profiles:this.callGraphs.map(e=>e.toProfile())}:null}frameInfo(){const e=this.filename||"(unknown)",t=this.functionName||"(unknown)";return{key:`${e}:${t}`,name:t,file:e}}calleeFrameInfo(){const e=this.calleeFilename||"(unknown)",t=this.calleeFunctionName||"(unknown)";return{key:`${e}:${t}`,name:t,file:e}}parseHeaderLine(e){const t=/^\s*(\w+):\s*(.*)+$/.exec(e);if(!t)return!1;if("events"!==t[1])return!0;const i=t[2].split(" ");if(null!=this.callGraphs)throw new Error(`Duplicate "events: " lines specified. First was "${this.eventsLine}", now received "${e}" on ${this.lineNum}.`);return this.callGraphs=i.map(e=>new s(this.importedFileName,e)),!0}parseAssignmentLine(e){const t=/^(\w+)=\s*(.*)$/.exec(e);if(!t)return!1;const i=t[1],s=t[2];switch(i){case"fe":case"fi":case"fl":this.filename=this.parseNameWithCompression(s,this.savedFileNames),this.calleeFilename=this.filename;break;case"fn":this.functionName=this.parseNameWithCompression(s,this.savedFunctionNames);break;case"cfi":case"cfl":this.calleeFilename=this.parseNameWithCompression(s,this.savedFileNames);break;case"cfn":this.calleeFunctionName=this.parseNameWithCompression(s,this.savedFunctionNames);break;case"calls":this.parseCostLine(this.lines[this.lineNum++],"child");break;default:console.log(`Ignoring assignment to unrecognized key "${e}" on line ${this.lineNum}`)}return!0}parseNameWithCompression(e,t){{const i=/^\((\d+)\)\s*(.+)$/.exec(e);if(i){const e=i[1],s=i[2];if(e in t)throw new Error(`Redefinition of name with id: ${e}. Original value was "${t[e]}". Tried to redefine as "${s}" on line ${this.lineNum}.`);return t[e]=s,s}}{const i=/^\((\d+)\)$/.exec(e);if(i){const e=i[1];if(!(e in t))throw new Error(`Tried to use name with id ${e} on line ${this.lineNum} before it was defined.`);return t[e]}}return e}parseCostLine(e,t){const i=e.split(/\s+/),s=[];for(let n of i){const e=parseInt(n);if(isNaN(e))return!1;s.push(e)}if(0==s.length)return!1;if(!this.callGraphs)throw new Error(`Encountered a cost line on line ${this.lineNum} before event specification was provided.`);for(let n=0;n<this.callGraphs.length;n++)"self"===t?this.callGraphs[n].addSelfWeight(this.frameInfo(),s[1+n]):"child"===t&&this.callGraphs[n].addChildWithTotalWeight(this.frameInfo(),this.calleeFrameInfo(),s[1+n]||0);return!0}}function r(e,t){return new n(e,t).parse()}
114
116
  },{"../lib/profile":"YG8z","../lib/utils":"ucYa","../lib/value-formatters":"LsM4"}],"uRa7":[function(require,module,exports) {
115
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.importProfileGroupFromText=F,exports.importProfileGroupFromBase64=I,exports.importProfilesFromFile=x,exports.importProfilesFromArrayBuffer=v,exports.importFromFileSystemDirectoryEntry=q;var r=require("./chrome"),e=require("./stackprof"),o=require("./instruments"),i=require("./bg-flamegraph"),t=require("./firefox"),n=require("../lib/file-format"),s=require("./v8proflog"),l=require("./linux-tools-perf"),p=require("./haskell"),m=require("./safari"),a=require("./utils"),f=require("./pprof"),u=require("../lib/utils"),c=require("./v8heapalloc"),d=require("./trace-event"),g=require("./callgrind"),h=function(r,e,o,i){return new(o||(o=Promise))(function(t,n){function s(r){try{p(i.next(r))}catch(e){n(e)}}function l(r){try{p(i.throw(r))}catch(e){n(e)}}function p(r){var e;r.done?t(r.value):(e=r.value,e instanceof o?e:new o(function(r){r(e)})).then(s,l)}p((i=i.apply(r,e||[])).next())})};function F(r,e){return h(this,void 0,void 0,function*(){return yield y(new a.TextProfileDataSource(r,e))})}function I(r,e){return h(this,void 0,void 0,function*(){return yield y(a.MaybeCompressedDataReader.fromArrayBuffer(r,(0,u.decodeBase64)(e).buffer))})}function x(r){return h(this,void 0,void 0,function*(){return y(a.MaybeCompressedDataReader.fromFile(r))})}function v(r,e){return h(this,void 0,void 0,function*(){return y(a.MaybeCompressedDataReader.fromArrayBuffer(r,e))})}function y(r){return h(this,void 0,void 0,function*(){const e=yield r.name(),o=yield S(r);if(o){o.name||(o.name=e);for(let r of o.profiles)r&&!r.getName()&&r.setName(e);return o}return null})}function P(r){return r?{name:r.getName(),indexToView:0,profiles:[r]}:null}function C(r){return"["===(r=r.trim())[0]&&"]"!==(r=r.replace(/,\s*$/,""))[r.length-1]&&(r+="]"),r}function S(a){return h(this,void 0,void 0,function*(){const u=yield a.name(),h=yield a.readAsArrayBuffer();{const r=(0,f.importAsPprofProfile)(h);if(r)return console.log("Importing as protobuf encoded pprof file"),P(r)}const F=yield a.readAsText();if(u.endsWith(".speedscope.json"))return console.log("Importing as speedscope json file"),(0,n.importSpeedscopeProfiles)(JSON.parse(F));if(u.endsWith(".chrome.json")||/Profile-\d{8}T\d{6}/.exec(u))return console.log("Importing as Chrome Timeline"),(0,r.importFromChromeTimeline)(JSON.parse(F),u);if(u.endsWith(".stackprof.json"))return console.log("Importing as stackprof profile"),P((0,e.importFromStackprof)(JSON.parse(F)));if(u.endsWith(".instruments.txt"))return console.log("Importing as Instruments.app deep copy"),P((0,o.importFromInstrumentsDeepCopy)(F));if(u.endsWith(".linux-perf.txt"))return console.log("Importing as output of linux perf script"),(0,l.importFromLinuxPerf)(F);if(u.endsWith(".collapsedstack.txt"))return console.log("Importing as collapsed stack format"),P((0,i.importFromBGFlameGraph)(F));if(u.endsWith(".v8log.json"))return console.log("Importing as --prof-process v8 log"),P((0,s.importFromV8ProfLog)(JSON.parse(F)));if(u.endsWith(".heapprofile"))return console.log("Importing as Chrome Heap Profile"),P((0,c.importFromChromeHeapProfile)(JSON.parse(F)));if(u.endsWith("-recording.json"))return console.log("Importing as Safari profile"),P((0,m.importFromSafari)(JSON.parse(F)));if(u.startsWith("callgrind."))return console.log("Importing as Callgrind profile"),(0,g.importFromCallgrind)(F,u);let I;try{I=JSON.parse(C(F))}catch(x){}if(I){if("https://www.speedscope.app/file-format-schema.json"===I.$schema)return console.log("Importing as speedscope json file"),(0,n.importSpeedscopeProfiles)(JSON.parse(F));if(I.systemHost&&"Firefox"==I.systemHost.name)return console.log("Importing as Firefox profile"),P((0,t.importFromFirefox)(I));if((0,r.isChromeTimeline)(I))return console.log("Importing as Chrome Timeline"),(0,r.importFromChromeTimeline)(I,u);if("nodes"in I&&"samples"in I&&"timeDeltas"in I)return console.log("Importing as Chrome CPU Profile"),P((0,r.importFromChromeCPUProfile)(I));if((0,d.isTraceEventFormatted)(I))return console.log("Importing as Trace Event Format profile"),(0,d.importTraceEvents)(I);if("head"in I&&"samples"in I&&"timestamps"in I)return console.log("Importing as Chrome CPU Profile (old format)"),P((0,r.importFromOldV8CPUProfile)(I));if("mode"in I&&"frames"in I&&"raw_timestamp_deltas"in I)return console.log("Importing as stackprof profile"),P((0,e.importFromStackprof)(I));if("code"in I&&"functions"in I&&"ticks"in I)return console.log("Importing as --prof-process v8 log"),P((0,s.importFromV8ProfLog)(I));if("head"in I&&"selfSize"in I.head)return console.log("Importing as Chrome Heap Profile"),P((0,c.importFromChromeHeapProfile)(JSON.parse(F)));if("rts_arguments"in I&&"initial_capabilities"in I)return console.log("Importing as Haskell GHC JSON Profile"),(0,p.importFromHaskell)(I);if("recording"in I&&"sampleStackTraces"in I.recording)return console.log("Importing as Safari profile"),P((0,m.importFromSafari)(JSON.parse(F)))}else{if(/^# callgrind format/.exec(F)||/^events:/m.exec(F)&&/^fn=/m.exec(F))return console.log("Importing as Callgrind profile"),(0,g.importFromCallgrind)(F,u);if(/^[\w \t\(\)]*\tSymbol Name/.exec(F))return console.log("Importing as Instruments.app deep copy"),P((0,o.importFromInstrumentsDeepCopy)(F));const r=F.split(/\n/).length;if(r>=1&&r===F.split(/ \d+\r?\n/).length)return console.log("Importing as collapsed stack format"),P((0,i.importFromBGFlameGraph)(F));const e=(0,l.importFromLinuxPerf)(F);if(e)return console.log("Importing from linux perf script output"),e}return null})}function q(r){return h(this,void 0,void 0,function*(){return(0,o.importFromInstrumentsTrace)(r)})}
117
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.importProfileGroupFromText=F,exports.importProfileGroupFromBase64=I,exports.importProfilesFromFile=x,exports.importProfilesFromArrayBuffer=C,exports.importFromFileSystemDirectoryEntry=S;var r=require("./chrome"),e=require("./stackprof"),o=require("./instruments"),i=require("./bg-flamegraph"),t=require("./firefox"),n=require("../lib/file-format"),s=require("./v8proflog"),l=require("./linux-tools-perf"),m=require("./haskell"),p=require("./safari"),a=require("./utils"),f=require("./pprof"),u=require("../lib/utils"),c=require("./v8heapalloc"),d=require("./trace-event"),g=require("./callgrind"),h=function(r,e,o,i){return new(o||(o=Promise))(function(t,n){function s(r){try{m(i.next(r))}catch(e){n(e)}}function l(r){try{m(i.throw(r))}catch(e){n(e)}}function m(r){var e;r.done?t(r.value):(e=r.value,e instanceof o?e:new o(function(r){r(e)})).then(s,l)}m((i=i.apply(r,e||[])).next())})};function F(r,e){return h(this,void 0,void 0,function*(){return yield v(new a.TextProfileDataSource(r,e))})}function I(r,e){return h(this,void 0,void 0,function*(){return yield v(a.MaybeCompressedDataReader.fromArrayBuffer(r,(0,u.decodeBase64)(e).buffer))})}function x(r){return h(this,void 0,void 0,function*(){return v(a.MaybeCompressedDataReader.fromFile(r))})}function C(r,e){return h(this,void 0,void 0,function*(){return v(a.MaybeCompressedDataReader.fromArrayBuffer(r,e))})}function v(r){return h(this,void 0,void 0,function*(){const e=yield r.name(),o=yield P(r);if(o){o.name||(o.name=e);for(let r of o.profiles)r&&!r.getName()&&r.setName(e);return o}return null})}function y(r){return r?{name:r.getName(),indexToView:0,profiles:[r]}:null}function P(a){return h(this,void 0,void 0,function*(){const u=yield a.name(),h=yield a.readAsArrayBuffer();{const r=(0,f.importAsPprofProfile)(h);if(r)return console.log("Importing as protobuf encoded pprof file"),y(r)}const F=yield a.readAsText();if(u.endsWith(".speedscope.json"))return console.log("Importing as speedscope json file"),(0,n.importSpeedscopeProfiles)(F.parseAsJSON());if(u.endsWith(".chrome.json")||/Profile-\d{8}T\d{6}/.exec(u))return console.log("Importing as Chrome Timeline"),(0,r.importFromChromeTimeline)(F.parseAsJSON(),u);if(u.endsWith(".stackprof.json"))return console.log("Importing as stackprof profile"),y((0,e.importFromStackprof)(F.parseAsJSON()));if(u.endsWith(".instruments.txt"))return console.log("Importing as Instruments.app deep copy"),y((0,o.importFromInstrumentsDeepCopy)(F));if(u.endsWith(".linux-perf.txt"))return console.log("Importing as output of linux perf script"),(0,l.importFromLinuxPerf)(F);if(u.endsWith(".collapsedstack.txt"))return console.log("Importing as collapsed stack format"),y((0,i.importFromBGFlameGraph)(F));if(u.endsWith(".v8log.json"))return console.log("Importing as --prof-process v8 log"),y((0,s.importFromV8ProfLog)(F.parseAsJSON()));if(u.endsWith(".heapprofile"))return console.log("Importing as Chrome Heap Profile"),y((0,c.importFromChromeHeapProfile)(F.parseAsJSON()));if(u.endsWith("-recording.json"))return console.log("Importing as Safari profile"),y((0,p.importFromSafari)(F.parseAsJSON()));if(u.startsWith("callgrind."))return console.log("Importing as Callgrind profile"),(0,g.importFromCallgrind)(F,u);let I;try{I=F.parseAsJSON()}catch(x){}if(I){if("https://www.speedscope.app/file-format-schema.json"===I.$schema)return console.log("Importing as speedscope json file"),(0,n.importSpeedscopeProfiles)(I);if(I.systemHost&&"Firefox"==I.systemHost.name)return console.log("Importing as Firefox profile"),y((0,t.importFromFirefox)(I));if((0,r.isChromeTimeline)(I))return console.log("Importing as Chrome Timeline"),(0,r.importFromChromeTimeline)(I,u);if("nodes"in I&&"samples"in I&&"timeDeltas"in I)return console.log("Importing as Chrome CPU Profile"),y((0,r.importFromChromeCPUProfile)(I));if((0,d.isTraceEventFormatted)(I))return console.log("Importing as Trace Event Format profile"),(0,d.importTraceEvents)(I);if("head"in I&&"samples"in I&&"timestamps"in I)return console.log("Importing as Chrome CPU Profile (old format)"),y((0,r.importFromOldV8CPUProfile)(I));if("mode"in I&&"frames"in I&&"raw_timestamp_deltas"in I)return console.log("Importing as stackprof profile"),y((0,e.importFromStackprof)(I));if("code"in I&&"functions"in I&&"ticks"in I)return console.log("Importing as --prof-process v8 log"),y((0,s.importFromV8ProfLog)(I));if("head"in I&&"selfSize"in I.head)return console.log("Importing as Chrome Heap Profile"),y((0,c.importFromChromeHeapProfile)(I));if("rts_arguments"in I&&"initial_capabilities"in I)return console.log("Importing as Haskell GHC JSON Profile"),(0,m.importFromHaskell)(I);if("recording"in I&&"sampleStackTraces"in I.recording)return console.log("Importing as Safari profile"),y((0,p.importFromSafari)(I))}else{if(/^# callgrind format/.exec(F.firstChunk())||/^events:/m.exec(F.firstChunk())&&/^fn=/m.exec(F.firstChunk()))return console.log("Importing as Callgrind profile"),(0,g.importFromCallgrind)(F,u);if(/^[\w \t\(\)]*\tSymbol Name/.exec(F.firstChunk()))return console.log("Importing as Instruments.app deep copy"),y((0,o.importFromInstrumentsDeepCopy)(F));const r=(0,l.importFromLinuxPerf)(F);if(r)return console.log("Importing from linux perf script output"),r;const e=(0,i.importFromBGFlameGraph)(F);if(e)return console.log("Importing as collapsed stack format"),y(e)}return null})}function S(r){return h(this,void 0,void 0,function*(){return(0,o.importFromInstrumentsTrace)(r)})}
116
118
  },{"./chrome":"kWV1","./stackprof":"I37H","./instruments":"G28U","./bg-flamegraph":"flbo","./firefox":"uNW1","../lib/file-format":"Xzb6","./v8proflog":"QV03","./linux-tools-perf":"f2sa","./haskell":"jm73","./safari":"jP3w","./utils":"QTYz","./pprof":"VmHy","../lib/utils":"ucYa","./v8heapalloc":"bNW7","./trace-event":"KFvE","./callgrind":"TZYa"}]},{},[], null)
117
- //# sourceMappingURL=import.e3a73ef4.js.map
119
+ //# sourceMappingURL=import.a03bf119.js.map