PageSourceSearch

https://boajs.dev/assets/js/4068d3ba.77db44c7.js

js boajs.dev collected 2026-10-02 03:07:43 UTC 12,422 bytes, 275 lines download raw bytes

1"use strict";
2(globalThis["webpackChunkboajs_dev"] ||= []).push([[9797],{
3
4/***/ 4536
5(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
6
7// ESM COMPAT FLAG
8__webpack_require__.r(__webpack_exports__);
9
10// EXPORTS
11__webpack_require__.d(__webpack_exports__, {
12  assets: () => (/* binding */ profiling_assets),
13  contentTitle: () => (/* binding */ contentTitle),
14  "default": () => (/* binding */ MDXContent),
15  frontMatter: () => (/* binding */ frontMatter),
16  metadata: () => (/* reexport */ site_docs_profiling_md_406_namespaceObject),
17  toc: () => (/* binding */ toc)
18});
19
20// MODULE: ./node_modules/url-loader/dist/cjs.js?limit=10000&name=assets/images/[name]-[contenthash].[ext]&fallback=/home/runner/work/boa-dev.github.io/boa-dev.github.io/node_modules/file-loader/dist/cjs.js!./static/doc-img/profiler.png
21var profiler_namespaceFn = /*#__PURE__*/__webpack_require__.cw(function(module, __webpack_exports__) {
22/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (__webpack_require__.p + "assets/images/profiler-1f1dba01fd288dcff446cc6a3cb42038.png");
23/* harmony export */ __webpack_require__.d(__webpack_exports__, [
24/* harmony export */   "A", 0, /* export default binding */ __WEBPACK_DEFAULT_EXPORT__
25/* harmony export */ ]);
26
27});
28
29;// ./.docusaurus/docusaurus-plugin-content-docs/default/site-docs-profiling-md-406.json
30const site_docs_profiling_md_406_namespaceObject = /*#__PURE__*/JSON.parse('{"id":"profiling","title":"Profiling","description":"Example","source":"@site/docs/profiling.md","sourceDirName":".","slug":"/profiling","permalink":"/docs/profiling","draft":false,"unlisted":false,"editUrl":"https://github.com/boa-dev/boa-dev.github.io/tree/main/docs/docs/profiling.md","tags":[],"version":"current","sidebarPosition":7,"frontMatter":{"sidebar_position":7},"sidebar":"infoSidebar","previous":{"title":"Shapes (Hidden Classes)","permalink":"/docs/optimizations/shapes"},"next":{"title":"Resources","permalink":"/docs/resources"}}');
31// EXTERNAL MODULE: ./node_modules/react/jsx-runtime.js
32var jsx_runtime = __webpack_require__(4848);
33// EXTERNAL MODULE: ./node_modules/@mdx-js/react/lib/index.js
34var lib = __webpack_require__(8453);
35;// ./docs/profiling.md
36
37
38const frontMatter = {
39	sidebar_position: 7
40};
41const contentTitle = 'Profiling';
42
43const profiling_assets = {
44
45};
46
47
48
49const toc = [{
50  "value": "Prerequisites",
51  "id": "prerequisites",
52  "level": 2
53}, {
54  "value": "How To Use",
55  "id": "how-to-use",
56  "level": 2
57}, {
58  "value": "Summarize",
59  "id": "summarize",
60  "level": 3
61}, {
62  "value": "More Information",
63  "id": "more-information",
64  "level": 2
65}];
66function _createMdxContent(props) {
67  const _components = {
68    a: "a",
69    code: "code",
70    h1: "h1",
71    h2: "h2",
72    h3: "h3",
73    header: "header",
74    img: "img",
75    li: "li",
76    p: "p",
77    pre: "pre",
78    ul: "ul",
79    ...(0,lib/* useMDXComponents */.R)(),
80    ...props.components
81  };
82  return (0,jsx_runtime.jsxs)(jsx_runtime.Fragment, {
83    children: [(0,jsx_runtime.jsx)(_components.header, {
84      children: (0,jsx_runtime.jsx)(_components.h1, {
85        id: "profiling",
86        children: "Profiling"
87      })
88    }), "\n", (0,jsx_runtime.jsx)(_components.p, {
89      children: (0,jsx_runtime.jsx)(_components.img, {
90        alt: "Example",
91        src: (profiler_namespaceFn().A) + "",
92        width: "3133",
93        height: "766"
94      })
95    }), "\n", (0,jsx_runtime.jsx)(_components.p, {
96      children: "It's possible to get a full profile of Boa in action.\nSometimes this is needed to figure out where it is spending most of it's time."
97    }), "\n", (0,jsx_runtime.jsxs)(_components.p, {
98      children: ["We use a crate called ", (0,jsx_runtime.jsx)(_components.a, {
99        href: "https://github.com/rust-lang/measureme",
100        children: "measureme"
101      }), ", which helps us keep track of timing functions during runtime."]
102    }), "\n", (0,jsx_runtime.jsx)(_components.p, {
103      children: "When the \"profiler\" flag is enabled, you compile with the profiler and it is called throughout the interpreter.\nwhen the feature flag is not enabled, you have an empty dummy implementation that is just no ops. rustc should completely optimize that away. So there should be no performance downgrade from these changes"
104    }), "\n", (0,jsx_runtime.jsx)(_components.h2, {
105      id: "prerequisites",
106      children: "Prerequisites"
107    }), "\n", (0,jsx_runtime.jsx)(_components.p, {
108      children: "Before continuing, please make sure the below prerequisites have been met."
109    }), "\n", (0,jsx_runtime.jsxs)(_components.ul, {
110      children: ["\n", (0,jsx_runtime.jsx)(_components.li, {
111        children: (0,jsx_runtime.jsx)(_components.a, {
112          href: "https://github.com/rust-lang/measureme/blob/master/crox/README.md",
113          children: "Crox"
114        })
115      }), "\n", (0,jsx_runtime.jsx)(_components.li, {
116        children: (0,jsx_runtime.jsx)(_components.a, {
117          href: "https://github.com/rust-lang/measureme/blob/master/summarize/README.md",
118          children: "summarize (Optional)"
119        })
120      }), "\n"]
121    }), "\n", (0,jsx_runtime.jsx)(_components.h2, {
122      id: "how-to-use",
123      children: "How To Use"
124    }), "\n", (0,jsx_runtime.jsx)(_components.p, {
125      children: "You can run boa using the \"profiler\" feature flag to enable profiling. Seeing as you'll most likely be using boa_cli you can pass this through, like so:"
126    }), "\n", (0,jsx_runtime.jsx)(_components.p, {
127      children: (0,jsx_runtime.jsx)(_components.code, {
128        children: "cargo run --release --features boa_engine/profiler ../tests/js/test.js"
129      })
130    }), "\n", (0,jsx_runtime.jsxs)(_components.p, {
131      children: ["Once finished you should see some trace files left in the directory (boa_cli in this case).\nIn the same directory as the ", (0,jsx_runtime.jsx)(_components.code, {
132        children: ".events, string_data, string_index"
133      }), " files run ", (0,jsx_runtime.jsx)(_components.code, {
134        children: "crox my_trace"
135      }), " or whatever the name of the files are. This will generate a chrome_profiler.json file, you can load this into Chrome Dev tools."]
136    }), "\n", (0,jsx_runtime.jsx)(_components.h3, {
137      id: "summarize",
138      children: "Summarize"
139    }), "\n", (0,jsx_runtime.jsxs)(_components.p, {
140      children: ["If you just want a summary of what functions were ran the most or where the most time was spent you can run ", (0,jsx_runtime.jsx)(_components.code, {
141        children: "summarize"
142      }), ".\nThis is the same as above except instead of calling ", (0,jsx_runtime.jsx)(_components.code, {
143        children: "$ crox my_trace"
144      }), " you call ", (0,jsx_runtime.jsx)(_components.code, {
145        children: "$ summarize summarize my_trace"
146      }), ". This will generate something like below:"]
147    }), "\n", (0,jsx_runtime.jsx)(_components.pre, {
148      children: (0,jsx_runtime.jsx)(_components.code, {
149        className: "language-md",
150        children: "+---------------------------------------+-----------+-----------------+----------+------------+\n| Item | Self time | % of total time | Time | Item count |\n+---------------------------------------+-----------+-----------------+----------+------------+\n| From<Object> | 1.04ms | 14.776 | 1.04ms | 146 |\n+---------------------------------------+-----------+-----------------+----------+------------+\n| new_object | 356.50µs | 5.082 | 533.50µs | 18 |\n+---------------------------------------+-----------+-----------------+----------+------------+\n| create_instrinsics | 263.50µs | 3.756 | 6.38ms | 1 |\n+---------------------------------------+-----------+-----------------+----------+------------+\n| make_builtin_fn: toString | 218.50µs | 3.114 | 290.50µs | 12 |\n+---------------------------------------+-----------+-----------------+----------+------------+\n| Value::get_field | 178.60µs | 2.546 | 340.20µs | 60 |\n+---------------------------------------+-----------+-----------------+----------+------------+\n| Value::get_property | 161.60µs | 2.303 | 161.60µs | 60 |\n+---------------------------------------+-----------+-----------------+----------+------------+\n| lex | 135.60µs | 1.933 | 135.60µs | 1 |\n+---------------------------------------+-----------+-----------------+----------+------------+\n| math:create | 125.40µs | 1.787 | 1.11ms | 1 |\n+---------------------------------------+-----------+-----------------+----------+------------+\n| Value::set_field | 100.20µs | 1.428 | 262.80µs | 8 |\n+---------------------------------------+-----------+-----------------+----------+------------+\n| function::builtin | 82.40µs | 1.175 | 82.40µs | 146 |\n+---------------------------------------+-----------+-----------------+----------+------------+\n| String | 81.60µs | 1.163 | 961.60µs | 1 |\n+---------------------------------------+-----------+-----------------+----------+------------+\n"
151      })
152    }), "\n", (0,jsx_runtime.jsx)(_components.h2, {
153      id: "more-information",
154      children: "More Information"
155    }), "\n", (0,jsx_runtime.jsxs)(_components.p, {
156      children: ["For more information, please see the ", (0,jsx_runtime.jsx)(_components.a, {
157        href: "./resources#profiling",
158        children: "profiling resources"
159      })]
160    })]
161  });
162}
163function MDXContent(props = {}) {
164  const {wrapper: MDXLayout} = {
165    ...(0,lib/* useMDXComponents */.R)(),
166    ...props.components
167  };
168  return MDXLayout ? (0,jsx_runtime.jsx)(MDXLayout, {
169    ...props,
170    children: (0,jsx_runtime.jsx)(_createMdxContent, {
171      ...props
172    })
173  }) : _createMdxContent(props);
174}
175
176
177
178/***/ },
179
180/***/ 8453
181(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
182
183/* harmony export */ __webpack_require__.d(__webpack_exports__, {
184/* harmony export */   R: () => (/* binding */ useMDXComponents),
185/* harmony export */   x: () => (/* binding */ MDXProvider)
186/* harmony export */ });
187/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(6540);
188/**
189 * @import {MDXComponents} from 'mdx/types.js'
190 * @import {Component, ReactElement, ReactNode} from 'react'
191 */
192
193/**
194 * @callback MergeComponents
195 *   Custom merge function.
196 * @param {Readonly<MDXComponents>} currentComponents
197 *   Current components from the context.
198 * @returns {MDXComponents}
199 *   Additional components.
200 *
201 * @typedef Props
202 *   Configuration for `MDXProvider`.
203 * @property {ReactNode | null | undefined} [children]
204 *   Children (optional).
205 * @property {Readonly<MDXComponents> | MergeComponents | null | undefined} [components]
206 *   Additional components to use or a function that creates them (optional).
207 * @property {boolean | null | undefined} [disableParentContext=false]
208 *   Turn off outer component context (default: `false`).
209 */
210
211
212
213/** @type {Readonly<MDXComponents>} */
214const emptyComponents = {}
215
216const MDXContext = react__WEBPACK_IMPORTED_MODULE_0__.createContext(emptyComponents)
217
218/**
219 * Get current components from the MDX Context.
220 *
221 * @param {Readonly<MDXComponents> | MergeComponents | null | undefined} [components]
222 *   Additional components to use or a function that creates them (optional).
223 * @returns {MDXComponents}
224 *   Current components.
225 */
226function useMDXComponents(components) {
227  const contextComponents = react__WEBPACK_IMPORTED_MODULE_0__.useContext(MDXContext)
228
229  // Memoize to avoid unnecessary top-level context changes
230  return react__WEBPACK_IMPORTED_MODULE_0__.useMemo(
231    function () {
232      // Custom merge via a function prop
233      if (typeof components === 'function') {
234        return components(contextComponents)
235      }
236
237      return {...contextComponents, ...components}
238    },
239    [contextComponents, components]
240  )
241}
242
243/**
244 * Provider for MDX context.
245 *
246 * @param {Readonly<Props>} properties
247 *   Properties.
248 * @returns {ReactElement}
249 *   Element.
250 * @satisfies {Component}
251 */
252function MDXProvider(properties) {
253  /** @type {Readonly<MDXComponents>} */
254  let allComponents
255
256  if (properties.disableParentContext) {
257    allComponents =
258      typeof properties.components === 'function'
259        ? properties.components(emptyComponents)
260        : properties.components || emptyComponents
261  } else {
262    allComponents = useMDXComponents(properties.components)
263  }
264
265  return react__WEBPACK_IMPORTED_MODULE_0__.createElement(
266    MDXContext.Provider,
267    {value: allComponents},
268    properties.children
269  )
270}
271
272
273/***/ }
274
275}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.