Files
Stanislaw Bialecki 7cb6e7b457 Ios instruments profiler (#21)
* feat:  rename previous profiler tools to react-profiler

* feat: add ios-instruments profiler with default tracetemplate

* fix: copying Argent.tracetemplate on install

* feat: enhance CPU profiling capabilities in react-profiler and ios-instruments + initial enable re-querying (investigating) the profiler output

* feat: enable analyzing old profiling sessions, enhance profiling tools interoperability

* refactor: stream react profiler data to files instead of runtime aggregate var

* chore: add xml-parser test

* chore: rm clg

* feat: ad ios-instruments timeout

* chore: cleanup reactProfilerAnalyze warning cond

* refactor: ensure not dividing by 0 in profilerCombinedReportTool

* fix: inject react commit-capture hook before startProfiling

* fix: rm main signature from rn framework trace analysis

* chore: writeReport fail

* fix: potential sampleIdx in parseCpuXml

* fix: timeDeltas[i] potentially undefined

* fix: decodeXml amp resolution sequence

* fix: rm rn-profiler skill from local repo

* feat: rename instruments to ios-profiler + improve react session stability
2026-03-19 11:16:22 +01:00

46 lines
1.3 KiB
TypeScript

import { describe, it, expect } from "vitest";
import { parseCpuXml } from "../../src/utils/ios-profiler/pipeline/xml-parser";
function makeXml(frameName: string): string {
return `<row>
<sample-time>1000</sample-time>
<thread fmt="main"></thread>
<weight>1000000</weight>
<backtrace id="1">
<frame id="1" name="${frameName}"/>
</backtrace>
</row>`;
}
function getFirstFrameName(xml: string): string {
const samples = parseCpuXml(xml);
return samples[0]?.stack[0]?.name ?? "";
}
describe("decodeXml (via parseCpuXml)", () => {
it("double-encoded entity decodes only once — &amp;lt; becomes &lt;, not <", () => {
const result = getFirstFrameName(makeXml("&amp;lt;tag&amp;gt;"));
expect(result).toBe("&lt;tag&gt;");
});
it("decodes &lt; and &gt; to angle brackets", () => {
const result = getFirstFrameName(makeXml("&lt;func&gt;"));
expect(result).toBe("<func>");
});
it("decodes &amp; to &", () => {
const result = getFirstFrameName(makeXml("&amp;"));
expect(result).toBe("&");
});
it("decodes &quot; to double quote", () => {
const result = getFirstFrameName(makeXml("&quot;hello&quot;"));
expect(result).toBe('"hello"');
});
it("decodes &apos; to single quote", () => {
const result = getFirstFrameName(makeXml("&apos;x&apos;"));
expect(result).toBe("'x'");
});
});