jsSelfProfiling.d.ts 880 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // Type definitions for https://wicg.github.io/js-self-profiling/
  2. declare namespace JSSelfProfiling {
  3. type Marker = 'script' | 'gc' | 'style' | 'layout' | 'paint' | 'other';
  4. type Sample = {
  5. timestamp: number;
  6. stackId: number;
  7. marker?: Marker;
  8. };
  9. type Stack = {
  10. frameId: number;
  11. parentId?: number;
  12. };
  13. type Frame = {
  14. name: string;
  15. resourceId?: number;
  16. line?: number;
  17. column?: number;
  18. };
  19. type Trace = {
  20. resources: string[];
  21. frames: Frame[];
  22. stacks: Stack[];
  23. samples: Sample[];
  24. };
  25. type BufferFullCallback = (trace: Trace) => void;
  26. interface Profiler {
  27. sampleInterval: number;
  28. stopped: boolean;
  29. new (options: {sampleInterval: number; maxBufferSize: number}): Profiler;
  30. addEventListener(event: 'samplebufferfull', callback: BufferFullCallback): void;
  31. stop: () => Promise<Trace>;
  32. }
  33. }